mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-01-12 17:52:41 +08:00
combine docs and src folders for profiles and proofs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Blockstack Inc.
|
||||
Copyright (c) 2017 Blockstack Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
276
README.md
276
README.md
@@ -1,20 +1,282 @@
|
||||
# Blockstack Connect
|
||||
|
||||
[](https://www.npmjs.com/package/blockstack)
|
||||
[](https://www.npmjs.com/package/blockstack)
|
||||
[](https://www.npmjs.com/package/blockstack)
|
||||
[](http://slack.blockstack.org/)
|
||||
|
||||
### Contents
|
||||
## Contents
|
||||
|
||||
* [About](#about)
|
||||
* [Installation](#installation)
|
||||
* [Modules](#modules)
|
||||
* [Profiles](#profiles)
|
||||
* [Proofs](#proofs)
|
||||
* [Wiki](#wiki)
|
||||
* [Testing](#testing)
|
||||
|
||||
### Installation
|
||||
## About
|
||||
|
||||
A library for working with cryptographically-signed JSON profiles.
|
||||
|
||||
This library can be used to:
|
||||
|
||||
1. transform a JSON profile into signed tokens
|
||||
1. recover a JSON profile from signed tokens
|
||||
1. validate signed profile tokens
|
||||
|
||||
*Note: this document uses ES6 in its examples but it is compiled down to Javascript (ES5) and is perfectly compatible with it. If you're using the latter, just make a few adjustments to the examples below (e.g. use "let" instead of "var").*
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install blockstack
|
||||
```
|
||||
|
||||
### Modules
|
||||
## Profiles
|
||||
|
||||
- [Auth](/auth)
|
||||
- [Profiles](/profiles)
|
||||
- [Proofs](/proofs)
|
||||
Follow these steps to create and register a profile for a Blockchain ID:
|
||||
|
||||
1. Create a JSON profile object
|
||||
2. Split up the profile into tokens, sign the tokens, and put them in a token file
|
||||
3. Create a zone file that points to the web location of the profile token file
|
||||
|
||||
#### Create a profile
|
||||
|
||||
```es6
|
||||
let balloonDog = {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
}
|
||||
```
|
||||
|
||||
#### Sign a profile as a single token
|
||||
|
||||
```es6
|
||||
import { PrivateKeychain, PublicKeychain } from 'blockstack-keychain'
|
||||
import { signToken, wrapToken } from 'blockstack'
|
||||
|
||||
let privateKeychain = new PrivateKeychain(),
|
||||
privateKey = privateKeychain.privateKey('hex'),
|
||||
publicKey = privateKeychain.publicKeychain.publicKey('hex')
|
||||
let token = signToken(balloonDog, privateKey, {publicKey: publicKey})
|
||||
let tokenRecord = wrapToken(token)
|
||||
console.log(token)
|
||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzMTc1MTFlOWVhY2Y0MmZlOGY3MTdmNzU3ODc2YzU1YmQ1ZDRjODgxOGViYWMxNzdiMzUwZmEyZDMzMzAwMTA2NiJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDMxNzUxMWU5ZWFjZjQyZmU4ZjcxN2Y3NTc4NzZjNTViZDVkNGM4ODE4ZWJhYzE3N2IzNTBmYTJkMzMzMDAxMDY2In0sImlzc3VlZEF0IjoiMjAxNi0wNC0xOFQyMzo0NTo1Mi40MTFaIiwiZXhwaXJlc0F0IjoiMjAxNy0wNC0xOFQyMzo0NTo1Mi40MTFaIn0.4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg
|
||||
console.log(tokenRecord)
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzMTc1MTFlOWVhY2Y0MmZlOGY3MTdmNzU3ODc2YzU1YmQ1ZDRjODgxOGViYWMxNzdiMzUwZmEyZDMzMzAwMTA2NiJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDMxNzUxMWU5ZWFjZjQyZmU4ZjcxN2Y3NTc4NzZjNTViZDVkNGM4ODE4ZWJhYzE3N2IzNTBmYTJkMzMzMDAxMDY2In0sImlzc3VlZEF0IjoiMjAxNi0wNC0xOFQyMzo0NTo1Mi40MTFaIiwiZXhwaXJlc0F0IjoiMjAxNy0wNC0xOFQyMzo0NTo1Mi40MTFaIn0.4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg",
|
||||
"data": {
|
||||
"header": {
|
||||
"typ": "JWT",
|
||||
"alg": "ES256K"
|
||||
},
|
||||
"payload": {
|
||||
"claim": {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
},
|
||||
"subject": {
|
||||
"publicKey": "0317511e9eacf42fe8f717f757876c55bd5d4c8818ebac177b350fa2d333001066"
|
||||
},
|
||||
"issuer": {
|
||||
"publicKey": "0317511e9eacf42fe8f717f757876c55bd5d4c8818ebac177b350fa2d333001066"
|
||||
},
|
||||
"issuedAt": "2016-04-18T23:45:52.411Z",
|
||||
"expiresAt": "2017-04-18T23:45:52.411Z"
|
||||
},
|
||||
"signature": "4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg"
|
||||
},
|
||||
"encrypted": false,
|
||||
"parentPublicKey": "02b511f1267a77f5814b2c07f03f1f112438d4be6f553dd4b877b2832874b4e706",
|
||||
"derivationEntropy": "1f8eaa7a916f05218cfc6904a3dab1a1ccd3ab69fbdd9d96a24db8c7445d118c"
|
||||
}
|
||||
```
|
||||
|
||||
#### Verify an individual token
|
||||
|
||||
```js
|
||||
import { verifyTokenRecord } from 'blockstack'
|
||||
|
||||
try {
|
||||
let decodedToken = verifyTokenRecord(tokenRecords[0], publicKeychain)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
```
|
||||
|
||||
#### Transform a profile to multiple signed tokens
|
||||
|
||||
```es6
|
||||
import { signTokenRecords } from 'blockstack'
|
||||
|
||||
let privateKeychain = new PrivateKeychain()
|
||||
let tokenRecords = signTokenRecords([balloonDog], privateKeychain)
|
||||
console.log(tokenRecords)
|
||||
[
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzYTU5ZGJmZDk2MTJlNDA4ODgxOGM5MGUxOWFmY2Y4ZDE3OTNiMzhhNWMwNDBjMzhkN2QwN2JiN2QzOWQ4NmQ3MiJ9LCJpc3N1ZWRBdCI6IjIwMTYtMDMtMTBUMTc6MDE6MzIuODc5WiIsImV4cGlyZXNBdCI6IjIwMTctMDMtMTBUMTc6MDE6MzIuODc5WiJ9.vEUJzl713FApgDNYzbUue5SDOdeElxEaAnMbmT-A6ihfrnzhOd5WvzlGJwTiz1LbeTruhQgbh_XyCJ6aLxfu6A",
|
||||
"data": {
|
||||
"header": {
|
||||
"typ": "JWT",
|
||||
"alg": "ES256K"
|
||||
},
|
||||
"payload": {
|
||||
"claim": {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
},
|
||||
"subject": {
|
||||
"publicKey": "03a59dbfd9612e4088818c90e19afcf8d1793b38a5c040c38d7d07bb7d39d86d72"
|
||||
},
|
||||
"issuedAt": "2016-03-10T17:01:32.879Z",
|
||||
"expiresAt": "2017-03-10T17:01:32.879Z"
|
||||
},
|
||||
"signature": "vEUJzl713FApgDNYzbUue5SDOdeElxEaAnMbmT-A6ihfrnzhOd5WvzlGJwTiz1LbeTruhQgbh_XyCJ6aLxfu6A"
|
||||
},
|
||||
"publicKey": "03a59dbfd9612e4088818c90e19afcf8d1793b38a5c040c38d7d07bb7d39d86d72",
|
||||
"encrypted": false,
|
||||
"parentPublicKey": "03be573c8dbdd74bbc457f530c4f5898f7147f105af57c1aee20127f981697b884",
|
||||
"derivationEntropy": "35d0d4e73780d7e47b404a961c9005f415db76ae88c1bcd4bdcd742d68670f26"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### Recover a profile from tokens
|
||||
|
||||
```js
|
||||
import { getProfileFromTokens } from 'blockstack'
|
||||
|
||||
let publicKeychain = privateKeychain.publicKeychain()
|
||||
let recoveredProfile = getProfileFromTokens(tokenRecords, publicKeychain)
|
||||
console.log(recoveredProfile)
|
||||
{ '@context': 'http://schema.org/',
|
||||
'@type': 'CreativeWork',
|
||||
name: 'Balloon Dog',
|
||||
creator:
|
||||
[ { '@type': 'Person',
|
||||
name: 'Jeff Koons',
|
||||
id: 'therealjeffkoons.id' } ],
|
||||
dateCreated: '1994-05-09T00:00:00-0400',
|
||||
datePublished: '2015-12-10T14:44:26-0500' }
|
||||
```
|
||||
|
||||
#### Validate profile schema
|
||||
|
||||
```js
|
||||
import { Person } from 'blockstack'
|
||||
let validationResults = Person.validateSchema(recoveredProfile)
|
||||
console.log(validationResults.valid)
|
||||
true
|
||||
```
|
||||
|
||||
## Proofs
|
||||
|
||||
#### Node
|
||||
|
||||
```es6
|
||||
import { validateProofs } from 'blockstack'
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
```es6
|
||||
let fullyQualifiedDomainName = "naval.id"
|
||||
validateProofs(profile, fullyQualifiedDomainName).then((proofs) => {
|
||||
console.log(proofs)
|
||||
})
|
||||
|
||||
|
||||
[
|
||||
{ "identifier": "naval",
|
||||
"proof_url": "https://twitter.com/naval/status/486609266212499456",
|
||||
"service": "twitter",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"identifier": "navalr",
|
||||
"proof_url": "https://facebook.com/navalr/posts/10152190734077261",
|
||||
"service": "facebook",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"identifier": "navalr",
|
||||
"proof_url": "https://gist.github.com/navalr/f31a74054f859ec0ac6a",
|
||||
"service": "github",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```
|
||||
$ npm run test
|
||||
```
|
||||
|
||||
#### Testing in a browser
|
||||
|
||||
*This test will only work with your browser's Cross-Origin Restrictions disabled.*
|
||||
|
||||
Run `npm run compile; npm run browserify` before opening the file `test.html`
|
||||
in your browser.
|
||||
|
||||
## Wiki
|
||||
|
||||
#### Names
|
||||
|
||||
A blockchain ID = a name + a profile, registered on a blockchain.
|
||||
|
||||
Let's say you register the name 'alice' within the 'id' namespace, the default namespace for identities for people. In this case, your "fully qualified name" name would be expressed as `alice.id`.
|
||||
|
||||
#### Profiles
|
||||
|
||||
Profile schemas are taken from schema.org. The schema for a person record can be found at http://schema.org/Person. There are some fields that have yet to be included, like the "account", "key", "policy", "id", and "publicKey" fields. An updated schema definition will be published to a different location that superclasses the schema.org Person definition and adds these fields.
|
||||
|
||||
#### Profile Storage
|
||||
|
||||
Blockchain ID profiles are stored in two files: a token file and a zone file:
|
||||
|
||||
+ **token file** - contains signed tokens with profile data
|
||||
+ **zone file** - describes where to find the token file
|
||||
|
||||
#### Lookups
|
||||
|
||||
An identity lookup is performed as follows:
|
||||
|
||||
1. lookup the name in blockstore's name records and get back the data hash associated with the name
|
||||
2. lookup the data hash in the blockstore DHT and get back the zone file
|
||||
3. scan the zone file for "zone origin" records and get the URL found in the "data" field - the token file URL
|
||||
4. issue a request to the token file URL and get back the token file
|
||||
5. parse through the token file for tokens and verify that all the tokens have valid signatures and that they can be tied back to the user's name (by using the public keychain)
|
||||
6. grab all of the claims in the tokens and merge them into a single JSON object, which is the user's profile
|
||||
|
||||
44
package.json
Normal file
44
package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "blockstack",
|
||||
"version": "0.2.0",
|
||||
"description": "The Blockstack Javascript library for identity and authentication.",
|
||||
"main": "lib/index",
|
||||
"scripts": {
|
||||
"browserify": "./node_modules/.bin/browserify lib/index.js --standalone BlockstackProofs -o ./src/testing/browser/blockstack-proofs.js",
|
||||
"compile": "rm -rf lib; babel --presets es2015 src -d lib",
|
||||
"prepublish": "npm run compile",
|
||||
"test": "npm run compile; npm run browserify; node lib/testing/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/blockstack/blockstack-connect.git"
|
||||
},
|
||||
"author": "Blockstack Inc.",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/blockstack/blockstack-connect/issues"
|
||||
},
|
||||
"homepage": "https://blockstack.org",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.4.5",
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"blue-tape": "^1.0.0",
|
||||
"browserify": "^13.1.1",
|
||||
"fetch-mock": "^5.5.0",
|
||||
"node-fetch": "^1.6.3",
|
||||
"tape": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"bigi": "^1.4.1",
|
||||
"bitcoinjs-lib": "git+ssh://git@github.com/shea256/bitcoinjs-lib.git",
|
||||
"blockstack-keychains": "0.0.4",
|
||||
"blockstack-zones": "0.0.1",
|
||||
"dateformat": "^1.0.12",
|
||||
"ecurve": "git+ssh://git@github.com/shea256/ecurve.git",
|
||||
"elliptic-curve": "^0.1.0",
|
||||
"hasprop": "0.0.4",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"jsontokens": "^0.6.2",
|
||||
"schema-inspector": "^1.6.4"
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
# Blockstack Profiles
|
||||
|
||||
[](https://circleci.com/gh/blockstack/blockstack-profiles-js/tree/master)
|
||||
[](https://www.npmjs.com/package/blockstack-profiles)
|
||||
[](https://www.npmjs.com/package/blockstack-profiles)
|
||||
[](https://www.npmjs.com/package/blockstack-profiles)
|
||||
[](http://slack.blockstack.org/)
|
||||
|
||||
### Contents
|
||||
|
||||
* [Installation](#installation)
|
||||
* [Importing](#importing)
|
||||
* [Registration](#registration)
|
||||
* [Profiles](#profiles)
|
||||
* [Zone Files](#zone-files)
|
||||
* [Wiki](#wiki)
|
||||
|
||||
A library for working with cryptographically-signed JSON profiles.
|
||||
|
||||
This library can be used to:
|
||||
|
||||
1. transform a JSON profile into signed tokens
|
||||
1. recover a JSON profile from signed tokens
|
||||
1. validate signed profile tokens
|
||||
|
||||
*Note: this document uses ES6 in its examples but it is compiled down to Javascript (ES5) and is perfectly compatible with it. If you're using the latter, just make a few adjustments to the examples below (e.g. use "let" instead of "var").*
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
$ npm install blockstack-profiles
|
||||
```
|
||||
|
||||
### Importing
|
||||
|
||||
#### ES6
|
||||
|
||||
```es6
|
||||
import {
|
||||
signToken, wrapToken, signTokenRecords,
|
||||
verifyTokenRecord, getProfileFromTokens,
|
||||
Profile, Person, Organization, CreativeWork,
|
||||
prepareZoneFileForHostedFile
|
||||
} from 'blockstack-profiles'
|
||||
import { PrivateKeychain, PublicKeychain } from 'blockstack-keychain'
|
||||
```
|
||||
|
||||
#### Node
|
||||
|
||||
```es6
|
||||
var blockstackProfiles = require('blockstack-profiles')
|
||||
var blockstackKeychain = require('blockstack-keychain')
|
||||
```
|
||||
|
||||
### Registration
|
||||
|
||||
Follow these steps to create and register a profile for a Blockchain ID:
|
||||
|
||||
1. Create a JSON profile object
|
||||
2. Split up the profile into tokens, sign the tokens, and put them in a token file
|
||||
3. Create a zone file that points to the web location of the profile token file
|
||||
|
||||
### Profiles
|
||||
|
||||
#### Create a profile
|
||||
|
||||
```es6
|
||||
let balloonDog = {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
}
|
||||
```
|
||||
|
||||
#### Sign a profile as a single token
|
||||
|
||||
```es6
|
||||
let privateKeychain = new PrivateKeychain(),
|
||||
privateKey = privateKeychain.privateKey('hex'),
|
||||
publicKey = privateKeychain.publicKeychain.publicKey('hex')
|
||||
let token = signToken(balloonDog, privateKey, {publicKey: publicKey})
|
||||
let tokenRecord = wrapToken(token)
|
||||
console.log(token)
|
||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzMTc1MTFlOWVhY2Y0MmZlOGY3MTdmNzU3ODc2YzU1YmQ1ZDRjODgxOGViYWMxNzdiMzUwZmEyZDMzMzAwMTA2NiJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDMxNzUxMWU5ZWFjZjQyZmU4ZjcxN2Y3NTc4NzZjNTViZDVkNGM4ODE4ZWJhYzE3N2IzNTBmYTJkMzMzMDAxMDY2In0sImlzc3VlZEF0IjoiMjAxNi0wNC0xOFQyMzo0NTo1Mi40MTFaIiwiZXhwaXJlc0F0IjoiMjAxNy0wNC0xOFQyMzo0NTo1Mi40MTFaIn0.4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg
|
||||
console.log(tokenRecord)
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzMTc1MTFlOWVhY2Y0MmZlOGY3MTdmNzU3ODc2YzU1YmQ1ZDRjODgxOGViYWMxNzdiMzUwZmEyZDMzMzAwMTA2NiJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDMxNzUxMWU5ZWFjZjQyZmU4ZjcxN2Y3NTc4NzZjNTViZDVkNGM4ODE4ZWJhYzE3N2IzNTBmYTJkMzMzMDAxMDY2In0sImlzc3VlZEF0IjoiMjAxNi0wNC0xOFQyMzo0NTo1Mi40MTFaIiwiZXhwaXJlc0F0IjoiMjAxNy0wNC0xOFQyMzo0NTo1Mi40MTFaIn0.4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg",
|
||||
"data": {
|
||||
"header": {
|
||||
"typ": "JWT",
|
||||
"alg": "ES256K"
|
||||
},
|
||||
"payload": {
|
||||
"claim": {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
},
|
||||
"subject": {
|
||||
"publicKey": "0317511e9eacf42fe8f717f757876c55bd5d4c8818ebac177b350fa2d333001066"
|
||||
},
|
||||
"issuer": {
|
||||
"publicKey": "0317511e9eacf42fe8f717f757876c55bd5d4c8818ebac177b350fa2d333001066"
|
||||
},
|
||||
"issuedAt": "2016-04-18T23:45:52.411Z",
|
||||
"expiresAt": "2017-04-18T23:45:52.411Z"
|
||||
},
|
||||
"signature": "4M-XodG4PaNm1NovKKo3gZVUMwG6aN7W9sVESqdZ4I9UaTB30jEuvqKWyD4aPcckw6SEEbZ1cBwgW9qXNXipzg"
|
||||
},
|
||||
"encrypted": false,
|
||||
"parentPublicKey": "02b511f1267a77f5814b2c07f03f1f112438d4be6f553dd4b877b2832874b4e706",
|
||||
"derivationEntropy": "1f8eaa7a916f05218cfc6904a3dab1a1ccd3ab69fbdd9d96a24db8c7445d118c"
|
||||
}
|
||||
```
|
||||
|
||||
#### Verify an individual token
|
||||
|
||||
```js
|
||||
try {
|
||||
let decodedToken = verifyTokenRecord(tokenRecords[0], publicKeychain)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
```
|
||||
|
||||
#### Transform a profile to multiple signed tokens
|
||||
|
||||
```es6
|
||||
let privateKeychain = new PrivateKeychain()
|
||||
let tokenRecords = signTokenRecords([balloonDog], privateKeychain)
|
||||
console.log(tokenRecords)
|
||||
[
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJjbGFpbSI6eyJAY29udGV4dCI6Imh0dHA6Ly9zY2hlbWEub3JnLyIsIkB0eXBlIjoiQ3JlYXRpdmVXb3JrIiwibmFtZSI6IkJhbGxvb24gRG9nIiwiY3JlYXRvciI6W3siQHR5cGUiOiJQZXJzb24iLCJAaWQiOiJ0aGVyZWFsamVmZmtvb25zLmlkIiwibmFtZSI6IkplZmYgS29vbnMifV0sImRhdGVDcmVhdGVkIjoiMTk5NC0wNS0wOVQwMDowMDowMC0wNDAwIiwiZGF0ZVB1Ymxpc2hlZCI6IjIwMTUtMTItMTBUMTQ6NDQ6MjYtMDUwMCJ9LCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzYTU5ZGJmZDk2MTJlNDA4ODgxOGM5MGUxOWFmY2Y4ZDE3OTNiMzhhNWMwNDBjMzhkN2QwN2JiN2QzOWQ4NmQ3MiJ9LCJpc3N1ZWRBdCI6IjIwMTYtMDMtMTBUMTc6MDE6MzIuODc5WiIsImV4cGlyZXNBdCI6IjIwMTctMDMtMTBUMTc6MDE6MzIuODc5WiJ9.vEUJzl713FApgDNYzbUue5SDOdeElxEaAnMbmT-A6ihfrnzhOd5WvzlGJwTiz1LbeTruhQgbh_XyCJ6aLxfu6A",
|
||||
"data": {
|
||||
"header": {
|
||||
"typ": "JWT",
|
||||
"alg": "ES256K"
|
||||
},
|
||||
"payload": {
|
||||
"claim": {
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
},
|
||||
"subject": {
|
||||
"publicKey": "03a59dbfd9612e4088818c90e19afcf8d1793b38a5c040c38d7d07bb7d39d86d72"
|
||||
},
|
||||
"issuedAt": "2016-03-10T17:01:32.879Z",
|
||||
"expiresAt": "2017-03-10T17:01:32.879Z"
|
||||
},
|
||||
"signature": "vEUJzl713FApgDNYzbUue5SDOdeElxEaAnMbmT-A6ihfrnzhOd5WvzlGJwTiz1LbeTruhQgbh_XyCJ6aLxfu6A"
|
||||
},
|
||||
"publicKey": "03a59dbfd9612e4088818c90e19afcf8d1793b38a5c040c38d7d07bb7d39d86d72",
|
||||
"encrypted": false,
|
||||
"parentPublicKey": "03be573c8dbdd74bbc457f530c4f5898f7147f105af57c1aee20127f981697b884",
|
||||
"derivationEntropy": "35d0d4e73780d7e47b404a961c9005f415db76ae88c1bcd4bdcd742d68670f26"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### Recover a profile from tokens
|
||||
|
||||
```js
|
||||
let publicKeychain = privateKeychain.publicKeychain()
|
||||
let recoveredProfile = getProfileFromTokens(tokenRecords, publicKeychain)
|
||||
console.log(recoveredProfile)
|
||||
{ '@context': 'http://schema.org/',
|
||||
'@type': 'CreativeWork',
|
||||
name: 'Balloon Dog',
|
||||
creator:
|
||||
[ { '@type': 'Person',
|
||||
name: 'Jeff Koons',
|
||||
id: 'therealjeffkoons.id' } ],
|
||||
dateCreated: '1994-05-09T00:00:00-0400',
|
||||
datePublished: '2015-12-10T14:44:26-0500' }
|
||||
```
|
||||
|
||||
#### Validate profile schema
|
||||
|
||||
```js
|
||||
> var validationResults = Person.validateSchema(recoveredProfile)
|
||||
> console.log(validationResults.valid)
|
||||
true
|
||||
```
|
||||
|
||||
### Wiki
|
||||
|
||||
#### Names
|
||||
|
||||
A blockchain ID = a name + a profile, registered on a blockchain.
|
||||
|
||||
Let's say you register the name 'alice' within the 'id' namespace, the default namespace for identities for people. In this case, your "fully qualified name" name would be expressed as `alice.id`.
|
||||
|
||||
#### Profiles
|
||||
|
||||
Profile schema is taken from schema.org. The schema for a person record can be found at http://schema.org/Person. There are some fields that have yet to be included, like the "account", "key", "policy", "id", and "publicKey" fields. An updated schema definition will be published to a different location that superclasses the schema.org Person definition and adds these fields.
|
||||
|
||||
#### Profile Storage
|
||||
|
||||
Blockchain ID profiles are stored in two files: a token file and a zone file:
|
||||
|
||||
+ **token file** - contains signed tokens with profile data
|
||||
+ **zone file** - describes where to find the token file
|
||||
|
||||
#### Lookups
|
||||
|
||||
An identity lookup is performed as follows:
|
||||
|
||||
1. lookup the name in blockstore's name records and get back the data hash associated with the name
|
||||
2. lookup the data hash in the blockstore DHT and get back the zone file
|
||||
3. scan the zone file for "zone origin" records and get the URL found in the "data" field - the token file URL
|
||||
4. issue a request to the token file URL and get back the token file
|
||||
5. parse through the token file for tokens and verify that all the tokens have valid signatures and that they can be tied back to the user's name (by using the public keychain)
|
||||
6. grab all of the claims in the tokens and merge them into a single JSON object, which is the user's profile
|
||||
@@ -1,83 +0,0 @@
|
||||
{
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "Person",
|
||||
"name": "Naval Ravikant",
|
||||
"givenName": "Naval",
|
||||
"familyName": "Ravikant",
|
||||
"description": "Co-founder of AngelList",
|
||||
"image": [
|
||||
{
|
||||
"@type": "ImageObject",
|
||||
"name": "avatar",
|
||||
"contentUrl": "https://pbs.twimg.com/profile_images/3696617328/667874c5936764d93d56ccc76a2bcc13.jpeg"
|
||||
},
|
||||
{
|
||||
"@type": "ImageObject",
|
||||
"name": "background",
|
||||
"contentUrl": "https://pbs.twimg.com/profile_banners/745273/1355705777/web_retina"
|
||||
}
|
||||
],
|
||||
"website": [
|
||||
{
|
||||
"@type": "WebSite",
|
||||
"url": "angel.co"
|
||||
}
|
||||
],
|
||||
"account": [
|
||||
{
|
||||
"@type": "Account",
|
||||
"service": "facebook",
|
||||
"identifier": "navalr",
|
||||
"proofType": "http",
|
||||
"proofUrl": "https://facebook.com/navalr/posts/10152190734077261"
|
||||
},
|
||||
{
|
||||
"@type": "Account",
|
||||
"service": "twitter",
|
||||
"identifier": "naval",
|
||||
"proofType": "http",
|
||||
"proofUrl": "https://twitter.com/naval/status/486609266212499456"
|
||||
},
|
||||
{
|
||||
"@type": "Account",
|
||||
"service": "github",
|
||||
"identifier": "navalr",
|
||||
"proofType": "http",
|
||||
"proofUrl": "https://gist.github.com/navalr/f31a74054f859ec0ac6a"
|
||||
},
|
||||
{
|
||||
"@type": "Account",
|
||||
"service": "bitcoin",
|
||||
"role": "payment",
|
||||
"identifier": "1919UrhYyhs471ps8CFcJ3DRpWSda8qtSk",
|
||||
"proofType": "signature",
|
||||
"proofMessage": "Verifying that +naval is my blockchain ID.",
|
||||
"proofSignature": "ICuRA+Dq5Dn8AiY9P+mcLzGyibPgG0ec9CphtMk512uPdB5eAncDSHhQZY/7kycvl6PLFEuR+j3OM/K2Vey1+EU="
|
||||
}
|
||||
],
|
||||
"worksFor": [
|
||||
{
|
||||
"@type": "Organization",
|
||||
"@id": "angellist.id"
|
||||
}
|
||||
],
|
||||
"knows": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "muneeb.id"
|
||||
},
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "ryan.id"
|
||||
}
|
||||
],
|
||||
"birthDate": "1973-01-01",
|
||||
"taxID": "000-00-0000",
|
||||
"address": {
|
||||
"@type": "PostalAddress",
|
||||
"streetAddress": "16 Maiden Ln",
|
||||
"addressLocality": "San Francisco, CA",
|
||||
"postalCode": "94108",
|
||||
"addressCountry": "United States"
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "blockstack-profiles",
|
||||
"version": "0.3.5",
|
||||
"description": "A JSON profile system where objects are cryptographically signed and reference one-another",
|
||||
"main": "lib/index",
|
||||
"scripts": {
|
||||
"compile": "rm -rf lib; babel --presets es2015 src -d lib",
|
||||
"test": "npm run compile; node lib/testing/unitTests.js",
|
||||
"prepublish": "npm run compile"
|
||||
},
|
||||
"author": "Halfmoon Labs, Inc.",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.4.5",
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"tape": "^4.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bigi": "^1.4.1",
|
||||
"bitcoinjs-lib": "git+ssh://git@github.com/shea256/bitcoinjs-lib.git",
|
||||
"blockstack-keychains": "0.0.4",
|
||||
"blockstack-zones": "0.0.1",
|
||||
"dateformat": "^1.0.12",
|
||||
"ecurve": "git+ssh://git@github.com/shea256/ecurve.git",
|
||||
"elliptic-curve": "^0.1.0",
|
||||
"hasprop": "0.0.4",
|
||||
"jwt-js": "^0.5.0",
|
||||
"schema-inspector": "^1.6.4"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export function nextYear() {
|
||||
return new Date(new Date().setFullYear(new Date().getFullYear() + 1))
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
# Blockstack Proofs
|
||||
|
||||
[](https://www.npmjs.com/package/blockstack-proofs)
|
||||
[](https://www.npmjs.com/package/blockstack-proofs)
|
||||
[](https://www.npmjs.com/package/blockstack-proofs)
|
||||
[](http://slack.blockstack.org/)
|
||||
|
||||
### Contents
|
||||
|
||||
* [Installation](#installation)
|
||||
* [Importing](#importing)
|
||||
* [Proofs](#proof)
|
||||
|
||||
A library for verifying blockstack profile proofs.
|
||||
|
||||
*Note: this document uses ES6 in its examples but it is compiled down to Javascript (ES5) and is perfectly compatible with it. If you're using the latter, just make a few adjustments to the examples below (e.g. use "let" instead of "var").*
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
$ npm install blockstack-proofs
|
||||
```
|
||||
|
||||
### Importing
|
||||
|
||||
#### ES6
|
||||
|
||||
```es6
|
||||
import {
|
||||
validateProofs
|
||||
} from 'blockstack-proofs'
|
||||
```
|
||||
|
||||
#### Node
|
||||
|
||||
```es6
|
||||
var blockstackProofs = require('blockstack-proofs')
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```es6
|
||||
let fqdn = "naval.id"
|
||||
validateProofs(profile, fqdn).then((proofs) => {
|
||||
console.log(proofs)
|
||||
})
|
||||
|
||||
|
||||
[
|
||||
{ "identifier": "naval",
|
||||
"proof_url": "https://twitter.com/naval/status/486609266212499456",
|
||||
"service": "twitter",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"identifier": "navalr",
|
||||
"proof_url": "https://facebook.com/navalr/posts/10152190734077261",
|
||||
"service": "facebook",
|
||||
"valid": true
|
||||
},
|
||||
{
|
||||
"identifier": "navalr",
|
||||
"proof_url": "https://gist.github.com/navalr/f31a74054f859ec0ac6a",
|
||||
"service": "github",
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
Run `npm run test` to run the test suite.
|
||||
|
||||
#### Testing in a browser
|
||||
|
||||
*This test will only work with your browser's Cross-Origin Restrictions disabled.*
|
||||
|
||||
Run `npm run compile; npm run browserify` before opening the file `test.html`
|
||||
in your browser.
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "CreativeWork",
|
||||
"name": "Balloon Dog",
|
||||
"creator": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "therealjeffkoons.id",
|
||||
"name": "Jeff Koons"
|
||||
}
|
||||
],
|
||||
"dateCreated": "1994-05-09T00:00:00-0400",
|
||||
"datePublished": "2015-12-10T14:44:26-0500"
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"@context": "http://schema.org/",
|
||||
"@type": "Organization",
|
||||
"name": "Google",
|
||||
"legalName": "Google Inc.",
|
||||
"email": "hello@google.org",
|
||||
"address": {
|
||||
"@type": "PostalAddress",
|
||||
"addressLocality": "Mountain View, CA",
|
||||
"postalCode": "94043",
|
||||
"streetAddress": "1600 Amphitheatre Parkway"
|
||||
},
|
||||
"employee": [
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "larrypage.id",
|
||||
"name": "Larry Page"
|
||||
},
|
||||
{
|
||||
"@type": "Person",
|
||||
"@id": "sergeybrin.id",
|
||||
"name": "Sergey Brin"
|
||||
}
|
||||
],
|
||||
"image": [
|
||||
{
|
||||
"@type": "ImageObject",
|
||||
"name": "logo",
|
||||
"contentUrl": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
|
||||
}
|
||||
],
|
||||
"parentOrganization": {
|
||||
"@type": "Organization",
|
||||
"@id": "alphabet.id",
|
||||
"name": "Alphabet Inc."
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"twitter": {
|
||||
"username": "naval",
|
||||
"proof": {
|
||||
"url": "https://twitter.com/naval/status/486609266212499456"
|
||||
}
|
||||
},
|
||||
"angellist": {
|
||||
"username": "naval"
|
||||
},
|
||||
"bitcoin": {
|
||||
"address": "1919UrhYyhs471ps8CFcJ3DRpWSda8qtSk"
|
||||
},
|
||||
"github": {
|
||||
"username": "navalr",
|
||||
"proof": {
|
||||
"url": "https://gist.github.com/navalr/f31a74054f859ec0ac6a"
|
||||
}
|
||||
},
|
||||
"website": "https://angel.co/naval",
|
||||
"pgp": {
|
||||
"url": "https://s3.amazonaws.com/pk9/naval",
|
||||
"fingerprint": "07354EDF5C6CF2572847840D8FA3F960B62B7C41"
|
||||
},
|
||||
"v": "0.2",
|
||||
"name": {
|
||||
"formatted": "Naval Ravikant"
|
||||
},
|
||||
"twitterUsername": "naval",
|
||||
"graph": {
|
||||
"url": "https://s3.amazonaws.com/grph/naval"
|
||||
},
|
||||
"cover": {
|
||||
"url": "https://pbs.twimg.com/profile_banners/745273/1355705777/web_retina"
|
||||
},
|
||||
"avatar": {
|
||||
"url": "https://pbs.twimg.com/profile_images/3696617328/667874c5936764d93d56ccc76a2bcc13.jpeg"
|
||||
},
|
||||
"bio": "Co-founder AngelList \u2022 Founder Epinions, Vast \u2022 Author Startupboy, Venture Hacks \u2022 Investor Twitter, Uber, Yammer, Postmates",
|
||||
"facebook": {
|
||||
"username": "navalr",
|
||||
"proof": {
|
||||
"url": "https://facebook.com/navalr/posts/10152190734077261"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"formatted": "San Francisco, CA"
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "blockstack-proofs",
|
||||
"version": "0.3.0",
|
||||
"description": "A library for verifying proofs (twitter, github, domains etc) linked to a Blockstack ID",
|
||||
"main": "lib/index",
|
||||
"scripts": {
|
||||
"compile": "rm -rf lib; babel --presets es2015 src -d lib",
|
||||
"test": "npm run compile; npm run browserify; node lib/testing/index.js",
|
||||
"prepublish": "npm run compile",
|
||||
"browserify": "./node_modules/.bin/browserify lib/index.js --standalone BlockstackProofs -o ./src/testing/browser/blockstack-proofs.js"
|
||||
},
|
||||
"author": "Blockstack Inc.",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.4.5",
|
||||
"babel-preset-es2015": "^6.18.0",
|
||||
"blue-tape": "^1.0.0",
|
||||
"browserify": "^13.1.1",
|
||||
"fetch-mock": "^5.5.0",
|
||||
"node-fetch": "^1.6.3",
|
||||
"tape": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"isomorphic-fetch": "^2.2.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/blockstack/blockstack-proofs-js.git"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import { validateProofs } from './proofs'
|
||||
|
||||
export {
|
||||
validateProofs
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/*
|
||||
* Profiles
|
||||
*/
|
||||
import { signToken, wrapToken, signTokenRecords } from './tokenSigning'
|
||||
import { verifyToken, verifyTokenRecord, getProfileFromTokens } from './tokenVerifying'
|
||||
|
||||
@@ -9,6 +12,11 @@ import { Person, Organization, CreativeWork, getPersonFromLegacyFormat } from '.
|
||||
import { makeZoneFileForHostedProfile } from './zoneFiles'
|
||||
import { nextYear } from './utils'
|
||||
|
||||
/*
|
||||
* Proofs
|
||||
*/
|
||||
import { validateProofs } from './proofs'
|
||||
|
||||
export {
|
||||
signToken,
|
||||
wrapToken,
|
||||
@@ -21,5 +29,6 @@ export {
|
||||
Person,
|
||||
Organization,
|
||||
CreativeWork,
|
||||
nextYear
|
||||
nextYear,
|
||||
validateProofs
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { containsValidProofStatement } from "../utils"
|
||||
import "isomorphic-fetch"
|
||||
|
||||
export class Service {
|
||||
|
||||
static validateProof(proof, fqdn) {
|
||||
@@ -1,7 +1,9 @@
|
||||
import { runProofsUnitTests } from './proofsUnitTests'
|
||||
import { runUtilsUnitTests } from './utilsUnitTests'
|
||||
import { runServicesUnitTests } from './servicesUnitTests'
|
||||
import { runProfilesUnitTests } from './profilesUnitTests'
|
||||
|
||||
runUtilsUnitTests()
|
||||
runServicesUnitTests()
|
||||
runProofsUnitTests()
|
||||
runProfilesUnitTests()
|
||||
@@ -180,9 +180,11 @@ function testSchemas() {
|
||||
})
|
||||
}
|
||||
|
||||
testVerifyToken()
|
||||
testTokening('naval.json', sampleProfiles.naval)
|
||||
testTokening('google.json', sampleProfiles.google)
|
||||
testTokening('balloonDog.json', sampleProfiles.balloonDog)
|
||||
testZoneFile()
|
||||
testSchemas()
|
||||
export function runProfilesUnitTests() {
|
||||
testVerifyToken()
|
||||
testTokening('naval.json', sampleProfiles.naval)
|
||||
testTokening('google.json', sampleProfiles.google)
|
||||
testTokening('balloonDog.json', sampleProfiles.balloonDog)
|
||||
testZoneFile()
|
||||
testSchemas()
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
import test from 'blue-tape'
|
||||
import fs from 'fs'
|
||||
import FetchMock from 'fetch-mock'
|
||||
import {
|
||||
validateProofs
|
||||
} from '../index'
|
||||
import { validateProofs } from '../index'
|
||||
import { sampleProfiles, sampleProofs, sampleVerifications } from './samples'
|
||||
|
||||
|
||||
function testProofs(profile, username, totalProofs) {
|
||||
mockRequests()
|
||||
|
||||
@@ -18,22 +15,17 @@ function testProofs(profile, username, totalProofs) {
|
||||
FetchMock.restore()
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mockRequests() {
|
||||
FetchMock.get(sampleVerifications.naval.facebook.url, sampleVerifications.naval.facebook.body)
|
||||
FetchMock.get(sampleVerifications.naval.github.url, sampleVerifications.naval.github.body)
|
||||
FetchMock.get(sampleVerifications.naval.twitter.url, sampleVerifications.naval.twitter.body)
|
||||
|
||||
FetchMock.get(sampleVerifications.larry.facebook.url, sampleVerifications.larry.facebook.body)
|
||||
|
||||
}
|
||||
|
||||
|
||||
export function runProofsUnitTests() {
|
||||
testProofs(sampleProfiles.naval, "naval.id", 3)
|
||||
testProofs(sampleProfiles.larry, "larry.id", 1)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
import {
|
||||
PrivateKeychain, PublicKeychain
|
||||
} from 'blockstack-keychains'
|
||||
import { PrivateKeychain, PublicKeychain } from 'blockstack-keychains'
|
||||
import { crypto as hashing, ECPair as EllipticKeyPair } from 'bitcoinjs-lib'
|
||||
import { decodeToken, TokenSigner } from 'jwt-js'
|
||||
import { decodeToken, TokenSigner } from 'jsontokens'
|
||||
import BigInteger from 'bigi'
|
||||
import { nextYear } from './utils'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
import { PrivateKeychain, PublicKeychain } from 'blockstack-keychains'
|
||||
import { decodeToken, TokenSigner, TokenVerifier } from 'jwt-js'
|
||||
import { decodeToken, TokenSigner, TokenVerifier } from 'jsontokens'
|
||||
|
||||
import BigInteger from 'bigi'
|
||||
import ecurve from 'ecurve'
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
export function nextYear() {
|
||||
return new Date(new Date().setFullYear(new Date().getFullYear() + 1))
|
||||
}
|
||||
|
||||
export function containsValidProofStatement(searchText, fqdn) {
|
||||
searchText = searchText.toLowerCase()
|
||||
Reference in New Issue
Block a user