├── .gitignore ├── README.md ├── download-swagger.js ├── lerna.json ├── package.json └── packages ├── go-client ├── .gitignore ├── .openapi-generator-ignore ├── .openapi-generator │ └── VERSION ├── .travis.yml ├── README.md ├── api │ └── openapi.yaml ├── api_bitswap.go ├── api_config.go ├── api_dag.go ├── api_dht.go ├── api_dns.go ├── api_files.go ├── api_key.go ├── api_name.go ├── api_pins.go ├── api_pubsub.go ├── api_repo.go ├── api_swarm.go ├── client.go ├── configuration.go ├── docs │ ├── BitswapApi.md │ ├── BitswapLedger.md │ ├── BitswapStats.md │ ├── Blocks.md │ ├── CidList.md │ ├── ConfigApi.md │ ├── Contents.md │ ├── CreatePinPayload.md │ ├── DagApi.md │ ├── DagLink.md │ ├── DagNode.md │ ├── DhtApi.md │ ├── DhtValue.md │ ├── DnsApi.md │ ├── FilesApi.md │ ├── GenerateKeypairPayload.md │ ├── IpnsOptions.md │ ├── IpnsRecord.md │ ├── KeyApi.md │ ├── Links.md │ ├── NameApi.md │ ├── Peer.md │ ├── Peers.md │ ├── Pin.md │ ├── PingPeerPayload.md │ ├── PingResponses.md │ ├── Pins.md │ ├── PinsApi.md │ ├── Pong.md │ ├── PubsubApi.md │ ├── RemotePeer.md │ ├── RemotePeers.md │ ├── RenameKeypairPayload.md │ ├── RepoApi.md │ ├── RepoStats.md │ ├── SubscribeToPubsubTopicPayload.md │ ├── SwamConnectToPeerPayload.md │ ├── SwarmApi.md │ ├── UnixfsEntry.md │ ├── UnixfsEntrySummary.md │ └── UpdateConfigBody.md ├── git_push.sh ├── model_bitswap_ledger.go ├── model_bitswap_stats.go ├── model_blocks.go ├── model_cid_list.go ├── model_contents.go ├── model_create_pin_payload.go ├── model_dag_link.go ├── model_dag_node.go ├── model_dht_value.go ├── model_generate_keypair_payload.go ├── model_ipns_options.go ├── model_ipns_record.go ├── model_links.go ├── model_peer.go ├── model_peers.go ├── model_pin.go ├── model_ping_peer_payload.go ├── model_ping_responses.go ├── model_pins.go ├── model_pong.go ├── model_remote_peer.go ├── model_remote_peers.go ├── model_rename_keypair_payload.go ├── model_repo_stats.go ├── model_subscribe_to_pubsub_topic_payload.go ├── model_swam_connect_to_peer_payload.go ├── model_unixfs_entry.go ├── model_unixfs_entry_summary.go ├── model_update_config_body.go └── response.go ├── go-server ├── .openapi-generator-ignore ├── .openapi-generator │ └── VERSION ├── Dockerfile ├── api │ └── openapi.yaml ├── go │ ├── README.md │ ├── api_bitswap.go │ ├── api_config.go │ ├── api_dag.go │ ├── api_dht.go │ ├── api_dns.go │ ├── api_files.go │ ├── api_key.go │ ├── api_name.go │ ├── api_pins.go │ ├── api_pubsub.go │ ├── api_repo.go │ ├── api_swarm.go │ ├── logger.go │ ├── model_bitswap_ledger.go │ ├── model_bitswap_stats.go │ ├── model_blocks.go │ ├── model_cid_list.go │ ├── model_contents.go │ ├── model_create_pin_payload.go │ ├── model_dag_link.go │ ├── model_dag_node.go │ ├── model_dht_value.go │ ├── model_generate_keypair_payload.go │ ├── model_ipns_options.go │ ├── model_ipns_record.go │ ├── model_links.go │ ├── model_peer.go │ ├── model_peers.go │ ├── model_pin.go │ ├── model_ping_peer_payload.go │ ├── model_ping_responses.go │ ├── model_pins.go │ ├── model_pong.go │ ├── model_remote_peer.go │ ├── model_remote_peers.go │ ├── model_rename_keypair_payload.go │ ├── model_repo_stats.go │ ├── model_subscribe_to_pubsub_topic_payload.go │ ├── model_swam_connect_to_peer_payload.go │ ├── model_unixfs_entry.go │ ├── model_unixfs_entry_summary.go │ ├── model_update_config_body.go │ └── routers.go └── main.go ├── js-graphql-server ├── index.js ├── package.json ├── resolvers │ ├── client.js │ ├── dag.js │ ├── files.js │ └── index.js └── schema │ └── index.js ├── js-http-server ├── index.js ├── nodemon.json ├── package.json └── server.js ├── js-rest-client ├── index.js └── package.json └── js-rest-server ├── index.js ├── package.json ├── routes ├── bitswap │ ├── index.js │ ├── ledger.js │ ├── reprovide.js │ ├── stats.js │ ├── unwant.js │ └── wantlist.js ├── config │ ├── get.js │ ├── index.js │ ├── patch.js │ ├── replace.js │ └── reset.js ├── dag │ ├── create.js │ ├── get.js │ ├── index.js │ ├── remove.js │ └── update.js ├── dht │ ├── find-peer.js │ ├── find-providers.js │ ├── get.js │ ├── index.js │ ├── provide.js │ ├── put.js │ └── query.js ├── files │ ├── create.js │ ├── get.js │ ├── index.js │ ├── remove.js │ ├── replace.js │ └── update.js ├── index.js ├── key │ ├── generate.js │ ├── index.js │ ├── list.js │ ├── remove.js │ └── rename.js ├── miscellaneous │ ├── dns.js │ └── index.js ├── name │ ├── index.js │ ├── publish.js │ └── resolve.js ├── pin │ ├── create.js │ ├── get.js │ ├── index.js │ ├── list.js │ └── remove.js ├── pubsub │ ├── index.js │ ├── list.js │ ├── peers.js │ ├── publish.js │ ├── subscribe.js │ └── unsubscribe.js ├── repo │ ├── gc.js │ ├── index.js │ └── stats.js └── swarm │ ├── add-filter.js │ ├── addrs.js │ ├── connect.js │ ├── disconnect.js │ ├── filters.js │ ├── index.js │ ├── peer.js │ ├── peers.js │ ├── ping.js │ └── remove-filter.js └── utils ├── mime-types.js ├── transform-hash.js └── validation ├── cid-base.js ├── cid-version.js └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .DS_Store 4 | Thumbs.db 5 | package-lock.json 6 | .vscode 7 | swagger.json 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ipfs-http 2 | 3 | What a future version of the IPFS HTTP API could look like, featuring [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) and [GraphQL](https://graphql.org/) endpoints with `js` and `go` implementations. 4 | 5 | Currently this project presents a façade over the existing HTTP API, so we can use it while working what we want out of a next gen API. 6 | 7 | ## Getting started 8 | 9 | ```console 10 | $ git clone https://github.com/ipfs-shipyard/ipfs-http 11 | $ cd ipfs-http 12 | $ npm i 13 | $ npm run start 14 | $ open http://localhost:8000/documentation 15 | $ open http://localhost:8000/graphql 16 | ``` 17 | -------------------------------------------------------------------------------- /download-swagger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | 5 | process.on('unhandledRejection', (error) => { 6 | throw error 7 | }) 8 | 9 | if (process.argv.length !== 3) { 10 | console.error('Please specify a path to write to!') 11 | process.exit(1) 12 | } 13 | 14 | const outputFile = process.argv[2] 15 | const createServer = require('./packages/js-http-server/server') 16 | 17 | const downloadSwaggerJson = async function () { 18 | const server = await createServer() 19 | const response = await server.inject({ method: 'GET', url: '/swagger.json' }) 20 | 21 | fs.writeFileSync(outputFile, JSON.stringify(response.result, null, 2)) 22 | 23 | process.exit(0) 24 | } 25 | 26 | downloadSwaggerJson() 27 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.9.0", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "version": "independent", 7 | "commands": { 8 | "bootstrap": { 9 | "hoist": true 10 | }, 11 | "run": { 12 | "stream": true 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipfs-http", 3 | "version": "1.0.0", 4 | "description": "A next-generation IPFS http/graphql interface", 5 | "license": "MIT", 6 | "scripts": { 7 | "postinstall": "lerna bootstrap", 8 | "reset": "lerna run --parallel reset && rm -rf node_modules && rm -rf package-lock.json && rm -rf yarn.lock", 9 | "test": "lerna run --parallel test", 10 | "build": "lerna run --parallel build", 11 | "deploy": "lerna run --parallel deploy", 12 | "start": "NODE_ENV=development lerna run --parallel start", 13 | "clean": "lerna run --parallel clean", 14 | "generate": "node download-swagger.js ./swagger.json && npm-run-all --parallel generate:*", 15 | "generate:go-client": "rm -rf ./packages/go-client/* && cd packages/go-client && openapi-generator generate -i ../../swagger.json -g go -o .", 16 | "generate:go-server": "rm -rf ./packages/go-server/* && cd packages/go-server && openapi-generator generate -i ../../swagger.json -g go-server -o ." 17 | }, 18 | "devDependencies": { 19 | "lerna": "^2.7.1", 20 | "npm-run-all": "^4.1.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/go-client/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /packages/go-client/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /packages/go-client/.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 3.2.3 -------------------------------------------------------------------------------- /packages/go-client/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | install: 4 | - go get -d -v . 5 | 6 | script: 7 | - go build -v ./ 8 | 9 | -------------------------------------------------------------------------------- /packages/go-client/api_dns.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | "fmt" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type DnsApiService service 27 | 28 | /* 29 | DnsApiService Resolve DNS links 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param path 32 | @return string 33 | */ 34 | func (a *DnsApiService) MiscellaneousDns(ctx context.Context, path string) (string, *http.Response, error) { 35 | var ( 36 | localVarHttpMethod = strings.ToUpper("Get") 37 | localVarPostBody interface{} 38 | localVarFormFileName string 39 | localVarFileName string 40 | localVarFileBytes []byte 41 | localVarReturnValue string 42 | ) 43 | 44 | // create path and map variables 45 | localVarPath := a.client.cfg.BasePath + "/dns/{path}" 46 | localVarPath = strings.Replace(localVarPath, "{"+"path"+"}", fmt.Sprintf("%v", path), -1) 47 | 48 | localVarHeaderParams := make(map[string]string) 49 | localVarQueryParams := url.Values{} 50 | localVarFormParams := url.Values{} 51 | 52 | // to determine the Content-Type header 53 | localVarHttpContentTypes := []string{} 54 | 55 | // set Content-Type header 56 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 57 | if localVarHttpContentType != "" { 58 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 59 | } 60 | 61 | // to determine the Accept header 62 | localVarHttpHeaderAccepts := []string{"application/json", "*/*"} 63 | 64 | // set Accept header 65 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 66 | if localVarHttpHeaderAccept != "" { 67 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 68 | } 69 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) 70 | if err != nil { 71 | return localVarReturnValue, nil, err 72 | } 73 | 74 | localVarHttpResponse, err := a.client.callAPI(r) 75 | if err != nil || localVarHttpResponse == nil { 76 | return localVarReturnValue, localVarHttpResponse, err 77 | } 78 | 79 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 80 | localVarHttpResponse.Body.Close() 81 | if err != nil { 82 | return localVarReturnValue, localVarHttpResponse, err 83 | } 84 | 85 | if localVarHttpResponse.StatusCode < 300 { 86 | // If we succeed, return the data, otherwise pass on to decode error. 87 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 88 | if err == nil { 89 | return localVarReturnValue, localVarHttpResponse, err 90 | } 91 | } 92 | 93 | if localVarHttpResponse.StatusCode >= 300 { 94 | newErr := GenericOpenAPIError{ 95 | body: localVarBody, 96 | error: localVarHttpResponse.Status, 97 | } 98 | if localVarHttpResponse.StatusCode == 200 { 99 | var v string 100 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 101 | if err != nil { 102 | newErr.error = err.Error() 103 | return localVarReturnValue, localVarHttpResponse, newErr 104 | } 105 | newErr.model = v 106 | return localVarReturnValue, localVarHttpResponse, newErr 107 | } 108 | return localVarReturnValue, localVarHttpResponse, newErr 109 | } 110 | 111 | return localVarReturnValue, localVarHttpResponse, nil 112 | } 113 | -------------------------------------------------------------------------------- /packages/go-client/configuration.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // contextKeys are used to identify the type of value in the context. 17 | // Since these are string, it is possible to get a short description of the 18 | // context key for logging and debugging using key.String(). 19 | 20 | type contextKey string 21 | 22 | func (c contextKey) String() string { 23 | return "auth " + string(c) 24 | } 25 | 26 | var ( 27 | // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. 28 | ContextOAuth2 = contextKey("token") 29 | 30 | // ContextBasicAuth takes BasicAuth as authentication for the request. 31 | ContextBasicAuth = contextKey("basic") 32 | 33 | // ContextAccessToken takes a string oauth2 access token as authentication for the request. 34 | ContextAccessToken = contextKey("accesstoken") 35 | 36 | // ContextAPIKey takes an APIKey as authentication for the request 37 | ContextAPIKey = contextKey("apikey") 38 | ) 39 | 40 | // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth 41 | type BasicAuth struct { 42 | UserName string `json:"userName,omitempty"` 43 | Password string `json:"password,omitempty"` 44 | } 45 | 46 | // APIKey provides API key based authentication to a request passed via context using ContextAPIKey 47 | type APIKey struct { 48 | Key string 49 | Prefix string 50 | } 51 | 52 | type Configuration struct { 53 | BasePath string `json:"basePath,omitempty"` 54 | Host string `json:"host,omitempty"` 55 | Scheme string `json:"scheme,omitempty"` 56 | DefaultHeader map[string]string `json:"defaultHeader,omitempty"` 57 | UserAgent string `json:"userAgent,omitempty"` 58 | HTTPClient *http.Client 59 | } 60 | 61 | func NewConfiguration() *Configuration { 62 | cfg := &Configuration{ 63 | BasePath: "http://localhost", 64 | DefaultHeader: make(map[string]string), 65 | UserAgent: "OpenAPI-Generator/1.0.0/go", 66 | } 67 | return cfg 68 | } 69 | 70 | func (c *Configuration) AddDefaultHeader(key string, value string) { 71 | c.DefaultHeader[key] = value 72 | } 73 | -------------------------------------------------------------------------------- /packages/go-client/docs/BitswapLedger.md: -------------------------------------------------------------------------------- 1 | # BitswapLedger 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Peer** | **string** | | [optional] 7 | **DebtRatio** | **float32** | | [optional] 8 | **Sent** | **int32** | | [optional] 9 | **Received** | **int32** | | [optional] 10 | **Exchanges** | **int32** | | [optional] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/go-client/docs/BitswapStats.md: -------------------------------------------------------------------------------- 1 | # BitswapStats 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Blocks** | [**Blocks**](blocks.md) | | [optional] 7 | **Data** | [**Blocks**](blocks.md) | | [optional] 8 | **ProvideBufferLength** | **int32** | | [optional] 9 | **Peers** | [**Peers**](peers.md) | | [optional] 10 | **Wantlist** | [**Peers**](peers.md) | | [optional] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/go-client/docs/Blocks.md: -------------------------------------------------------------------------------- 1 | # Blocks 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Sent** | **int32** | | [optional] 7 | **Received** | **int32** | | [optional] 8 | **Duplicate** | **int32** | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/go-client/docs/CidList.md: -------------------------------------------------------------------------------- 1 | # CidList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/ConfigApi.md: -------------------------------------------------------------------------------- 1 | # \ConfigApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**ConfigGet**](ConfigApi.md#ConfigGet) | **Get** /config | Returns the current config 8 | [**ConfigPatch**](ConfigApi.md#ConfigPatch) | **Patch** /config | Replaces part of the current config 9 | [**ConfigReplace**](ConfigApi.md#ConfigReplace) | **Put** /config | Replaces the current config 10 | [**ConfigReset**](ConfigApi.md#ConfigReset) | **Delete** /config | Resets the current config to default values 11 | 12 | 13 | # **ConfigGet** 14 | > string ConfigGet(ctx, ) 15 | Returns the current config 16 | 17 | ### Required Parameters 18 | This endpoint does not need any parameter. 19 | 20 | ### Return type 21 | 22 | **string** 23 | 24 | ### Authorization 25 | 26 | No authorization required 27 | 28 | ### HTTP request headers 29 | 30 | - **Content-Type**: Not defined 31 | - **Accept**: */* 32 | 33 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 34 | 35 | # **ConfigPatch** 36 | > string ConfigPatch(ctx, optional) 37 | Replaces part of the current config 38 | 39 | The daemon will have to be restarted manually for the changes to take effect 40 | 41 | ### Required Parameters 42 | 43 | Name | Type | Description | Notes 44 | ------------- | ------------- | ------------- | ------------- 45 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 46 | **optional** | ***ConfigPatchOpts** | optional parameters | nil if no parameters 47 | 48 | ### Optional Parameters 49 | Optional parameters are passed through a pointer to a ConfigPatchOpts struct 50 | 51 | Name | Type | Description | Notes 52 | ------------- | ------------- | ------------- | ------------- 53 | **updateConfigBody** | [**optional.Interface of UpdateConfigBody**](UpdateConfigBody.md)| | 54 | 55 | ### Return type 56 | 57 | **string** 58 | 59 | ### Authorization 60 | 61 | No authorization required 62 | 63 | ### HTTP request headers 64 | 65 | - **Content-Type**: Not defined 66 | - **Accept**: */* 67 | 68 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 69 | 70 | # **ConfigReplace** 71 | > string ConfigReplace(ctx, optional) 72 | Replaces the current config 73 | 74 | The daemon will have to be restarted manually for the changes to take effect 75 | 76 | ### Required Parameters 77 | 78 | Name | Type | Description | Notes 79 | ------------- | ------------- | ------------- | ------------- 80 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 81 | **optional** | ***ConfigReplaceOpts** | optional parameters | nil if no parameters 82 | 83 | ### Optional Parameters 84 | Optional parameters are passed through a pointer to a ConfigReplaceOpts struct 85 | 86 | Name | Type | Description | Notes 87 | ------------- | ------------- | ------------- | ------------- 88 | **updateConfigBody** | [**optional.Interface of UpdateConfigBody**](UpdateConfigBody.md)| | 89 | 90 | ### Return type 91 | 92 | **string** 93 | 94 | ### Authorization 95 | 96 | No authorization required 97 | 98 | ### HTTP request headers 99 | 100 | - **Content-Type**: Not defined 101 | - **Accept**: */* 102 | 103 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 104 | 105 | # **ConfigReset** 106 | > string ConfigReset(ctx, ) 107 | Resets the current config to default values 108 | 109 | The daemon will have to be restarted manually for the changes to take effect 110 | 111 | ### Required Parameters 112 | This endpoint does not need any parameter. 113 | 114 | ### Return type 115 | 116 | **string** 117 | 118 | ### Authorization 119 | 120 | No authorization required 121 | 122 | ### HTTP request headers 123 | 124 | - **Content-Type**: Not defined 125 | - **Accept**: */* 126 | 127 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 128 | 129 | -------------------------------------------------------------------------------- /packages/go-client/docs/Contents.md: -------------------------------------------------------------------------------- 1 | # Contents 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/CreatePinPayload.md: -------------------------------------------------------------------------------- 1 | # CreatePinPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Hash** | **string** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/go-client/docs/DagApi.md: -------------------------------------------------------------------------------- 1 | # \DagApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**DagCreate**](DagApi.md#DagCreate) | **Post** /dag | Store an IPLD format node 8 | [**DagGet**](DagApi.md#DagGet) | **Get** /dag/{cid} | Get a DAG node 9 | [**DagRemove**](DagApi.md#DagRemove) | **Delete** /dag/{cid} | Remove a DAG node from your local repo 10 | [**DagUpdate**](DagApi.md#DagUpdate) | **Patch** /dag/{cid} | Update an IPLD format node 11 | 12 | 13 | # **DagCreate** 14 | > string DagCreate(ctx, optional) 15 | Store an IPLD format node 16 | 17 | The dag API supports the creation and manipulation of dag-pb object, as well as other IPLD formats (i.e dag-cbor, ethereum-block, git, etc) 18 | 19 | ### Required Parameters 20 | 21 | Name | Type | Description | Notes 22 | ------------- | ------------- | ------------- | ------------- 23 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 24 | **optional** | ***DagCreateOpts** | optional parameters | nil if no parameters 25 | 26 | ### Optional Parameters 27 | Optional parameters are passed through a pointer to a DagCreateOpts struct 28 | 29 | Name | Type | Description | Notes 30 | ------------- | ------------- | ------------- | ------------- 31 | **format** | **optional.String**| | [default to dag-cbor] 32 | **hashAlg** | **optional.String**| | [default to sha2-256] 33 | **cidVersion** | **optional.Int32**| Which CID version to use | [default to 1] 34 | **dagNode** | [**optional.Interface of DagNode**](DagNode.md)| | 35 | 36 | ### Return type 37 | 38 | **string** 39 | 40 | ### Authorization 41 | 42 | No authorization required 43 | 44 | ### HTTP request headers 45 | 46 | - **Content-Type**: Not defined 47 | - **Accept**: */* 48 | 49 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 50 | 51 | # **DagGet** 52 | > string DagGet(ctx, cid, optional) 53 | Get a DAG node 54 | 55 | Resolves a DAG node with the passed CID 56 | 57 | ### Required Parameters 58 | 59 | Name | Type | Description | Notes 60 | ------------- | ------------- | ------------- | ------------- 61 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 62 | **cid** | **string**| The CID that corresponds to the DAG node we wish to retrieve | 63 | **optional** | ***DagGetOpts** | optional parameters | nil if no parameters 64 | 65 | ### Optional Parameters 66 | Optional parameters are passed through a pointer to a DagGetOpts struct 67 | 68 | Name | Type | Description | Notes 69 | ------------- | ------------- | ------------- | ------------- 70 | 71 | **cidBase** | **optional.String**| Which number base to use when returning a CID | [default to base32] 72 | **cidVersion** | **optional.Int32**| Which CID version to use | [default to 1] 73 | **path** | **optional.String**| Path to resolve within this DAGNode | 74 | **offset** | **optional.Int32**| Byte offset to start streaming from | 75 | **length** | **optional.Int32**| Max number of bytes to stream | 76 | **localResolve** | **optional.Bool**| If set to true, it will avoid resolving through different objects | [default to false] 77 | 78 | ### Return type 79 | 80 | **string** 81 | 82 | ### Authorization 83 | 84 | No authorization required 85 | 86 | ### HTTP request headers 87 | 88 | - **Content-Type**: Not defined 89 | - **Accept**: application/json, application/octet-stream, */* 90 | 91 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 92 | 93 | # **DagRemove** 94 | > string DagRemove(ctx, cid) 95 | Remove a DAG node from your local repo 96 | 97 | This will not remove a DAG node from IPFS if other nodes have it 98 | 99 | ### Required Parameters 100 | 101 | Name | Type | Description | Notes 102 | ------------- | ------------- | ------------- | ------------- 103 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 104 | **cid** | **string**| The CID that corresponds to the DAG node we wish to remove | 105 | 106 | ### Return type 107 | 108 | **string** 109 | 110 | ### Authorization 111 | 112 | No authorization required 113 | 114 | ### HTTP request headers 115 | 116 | - **Content-Type**: Not defined 117 | - **Accept**: */* 118 | 119 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 120 | 121 | # **DagUpdate** 122 | > string DagUpdate(ctx, cid, optional) 123 | Update an IPLD format node 124 | 125 | This will result in a new DAG node being created 126 | 127 | ### Required Parameters 128 | 129 | Name | Type | Description | Notes 130 | ------------- | ------------- | ------------- | ------------- 131 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 132 | **cid** | **string**| The CID that corresponds to the DAG node we wish to create | 133 | **optional** | ***DagUpdateOpts** | optional parameters | nil if no parameters 134 | 135 | ### Optional Parameters 136 | Optional parameters are passed through a pointer to a DagUpdateOpts struct 137 | 138 | Name | Type | Description | Notes 139 | ------------- | ------------- | ------------- | ------------- 140 | 141 | **format** | **optional.String**| | [default to dag-cbor] 142 | **hashAlg** | **optional.String**| | [default to sha2-256] 143 | **cidVersion** | **optional.Int32**| Which CID version to use | [default to 1] 144 | **dagNode** | [**optional.Interface of DagNode**](DagNode.md)| | 145 | 146 | ### Return type 147 | 148 | **string** 149 | 150 | ### Authorization 151 | 152 | No authorization required 153 | 154 | ### HTTP request headers 155 | 156 | - **Content-Type**: Not defined 157 | - **Accept**: */* 158 | 159 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 160 | 161 | -------------------------------------------------------------------------------- /packages/go-client/docs/DagLink.md: -------------------------------------------------------------------------------- 1 | # DagLink 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Name** | **string** | | [optional] 7 | **Size** | **int32** | | [optional] 8 | **Cid** | **string** | | 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/go-client/docs/DagNode.md: -------------------------------------------------------------------------------- 1 | # DagNode 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Data** | **string** | | [optional] 7 | **Links** | [**Links**](links.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/go-client/docs/DhtValue.md: -------------------------------------------------------------------------------- 1 | # DhtValue 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Value** | **string** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/go-client/docs/DnsApi.md: -------------------------------------------------------------------------------- 1 | # \DnsApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**MiscellaneousDns**](DnsApi.md#MiscellaneousDns) | **Get** /dns/{path} | Resolve DNS links 8 | 9 | 10 | # **MiscellaneousDns** 11 | > string MiscellaneousDns(ctx, path) 12 | Resolve DNS links 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **path** | **string**| | 20 | 21 | ### Return type 22 | 23 | **string** 24 | 25 | ### Authorization 26 | 27 | No authorization required 28 | 29 | ### HTTP request headers 30 | 31 | - **Content-Type**: Not defined 32 | - **Accept**: application/json, */* 33 | 34 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 35 | 36 | -------------------------------------------------------------------------------- /packages/go-client/docs/GenerateKeypairPayload.md: -------------------------------------------------------------------------------- 1 | # GenerateKeypairPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Name** | **string** | | 7 | **Pem** | **string** | base64 encoded PKCS #8 PEM file to import keypairs from | [optional] 8 | **Password** | **string** | Password to PKCS #8 PEM file | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/go-client/docs/IpnsOptions.md: -------------------------------------------------------------------------------- 1 | # IpnsOptions 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Value** | **string** | | 7 | **Resolve** | **bool** | Resolve given path before publishing | [optional] [default to false] 8 | **Lifetime** | **string** | Time duration of the record | [optional] [default to 24h] 9 | **Ttl** | **string** | Time duration this record should be cached | [optional] [default to 24h] 10 | **Key** | **string** | Name of the key to be used or Peer ID | [optional] [default to self] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/go-client/docs/IpnsRecord.md: -------------------------------------------------------------------------------- 1 | # IpnsRecord 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Name** | **string** | | [optional] 7 | **Value** | **string** | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/go-client/docs/KeyApi.md: -------------------------------------------------------------------------------- 1 | # \KeyApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**KeyGenerate**](KeyApi.md#KeyGenerate) | **Post** /key | Create a new keypair 8 | [**KeyList**](KeyApi.md#KeyList) | **Get** /key | List all local keypairs 9 | [**KeyRemove**](KeyApi.md#KeyRemove) | **Delete** /key/{name} | Remove a keypair 10 | [**KeyRename**](KeyApi.md#KeyRename) | **Patch** /key/{name} | Rename a keypair 11 | 12 | 13 | # **KeyGenerate** 14 | > string KeyGenerate(ctx, optional) 15 | Create a new keypair 16 | 17 | ### Required Parameters 18 | 19 | Name | Type | Description | Notes 20 | ------------- | ------------- | ------------- | ------------- 21 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 22 | **optional** | ***KeyGenerateOpts** | optional parameters | nil if no parameters 23 | 24 | ### Optional Parameters 25 | Optional parameters are passed through a pointer to a KeyGenerateOpts struct 26 | 27 | Name | Type | Description | Notes 28 | ------------- | ------------- | ------------- | ------------- 29 | **generateKeypairPayload** | [**optional.Interface of GenerateKeypairPayload**](GenerateKeypairPayload.md)| | 30 | 31 | ### Return type 32 | 33 | **string** 34 | 35 | ### Authorization 36 | 37 | No authorization required 38 | 39 | ### HTTP request headers 40 | 41 | - **Content-Type**: Not defined 42 | - **Accept**: application/json, */* 43 | 44 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 45 | 46 | # **KeyList** 47 | > string KeyList(ctx, ) 48 | List all local keypairs 49 | 50 | ### Required Parameters 51 | This endpoint does not need any parameter. 52 | 53 | ### Return type 54 | 55 | **string** 56 | 57 | ### Authorization 58 | 59 | No authorization required 60 | 61 | ### HTTP request headers 62 | 63 | - **Content-Type**: Not defined 64 | - **Accept**: application/json, */* 65 | 66 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 67 | 68 | # **KeyRemove** 69 | > string KeyRemove(ctx, name) 70 | Remove a keypair 71 | 72 | ### Required Parameters 73 | 74 | Name | Type | Description | Notes 75 | ------------- | ------------- | ------------- | ------------- 76 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 77 | **name** | **string**| | 78 | 79 | ### Return type 80 | 81 | **string** 82 | 83 | ### Authorization 84 | 85 | No authorization required 86 | 87 | ### HTTP request headers 88 | 89 | - **Content-Type**: Not defined 90 | - **Accept**: application/json, */* 91 | 92 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 93 | 94 | # **KeyRename** 95 | > string KeyRename(ctx, name, optional) 96 | Rename a keypair 97 | 98 | ### Required Parameters 99 | 100 | Name | Type | Description | Notes 101 | ------------- | ------------- | ------------- | ------------- 102 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 103 | **name** | **string**| | 104 | **optional** | ***KeyRenameOpts** | optional parameters | nil if no parameters 105 | 106 | ### Optional Parameters 107 | Optional parameters are passed through a pointer to a KeyRenameOpts struct 108 | 109 | Name | Type | Description | Notes 110 | ------------- | ------------- | ------------- | ------------- 111 | 112 | **renameKeypairPayload** | [**optional.Interface of RenameKeypairPayload**](RenameKeypairPayload.md)| | 113 | 114 | ### Return type 115 | 116 | **string** 117 | 118 | ### Authorization 119 | 120 | No authorization required 121 | 122 | ### HTTP request headers 123 | 124 | - **Content-Type**: Not defined 125 | - **Accept**: application/json, */* 126 | 127 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 128 | 129 | -------------------------------------------------------------------------------- /packages/go-client/docs/Links.md: -------------------------------------------------------------------------------- 1 | # Links 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/NameApi.md: -------------------------------------------------------------------------------- 1 | # \NameApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**NamePublish**](NameApi.md#NamePublish) | **Post** /name | Publish an IPNS name with a given value 8 | [**NameResolve**](NameApi.md#NameResolve) | **Get** /name/{name} | Resolve an IPNS name 9 | 10 | 11 | # **NamePublish** 12 | > IpnsRecord NamePublish(ctx, optional) 13 | Publish an IPNS name with a given value 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **optional** | ***NamePublishOpts** | optional parameters | nil if no parameters 21 | 22 | ### Optional Parameters 23 | Optional parameters are passed through a pointer to a NamePublishOpts struct 24 | 25 | Name | Type | Description | Notes 26 | ------------- | ------------- | ------------- | ------------- 27 | **ipnsOptions** | [**optional.Interface of IpnsOptions**](IpnsOptions.md)| | 28 | 29 | ### Return type 30 | 31 | [**IpnsRecord**](ipns-record.md) 32 | 33 | ### Authorization 34 | 35 | No authorization required 36 | 37 | ### HTTP request headers 38 | 39 | - **Content-Type**: Not defined 40 | - **Accept**: application/json, */* 41 | 42 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 43 | 44 | # **NameResolve** 45 | > string NameResolve(ctx, name, optional) 46 | Resolve an IPNS name 47 | 48 | ### Required Parameters 49 | 50 | Name | Type | Description | Notes 51 | ------------- | ------------- | ------------- | ------------- 52 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 53 | **name** | **string**| | 54 | **optional** | ***NameResolveOpts** | optional parameters | nil if no parameters 55 | 56 | ### Optional Parameters 57 | Optional parameters are passed through a pointer to a NameResolveOpts struct 58 | 59 | Name | Type | Description | Notes 60 | ------------- | ------------- | ------------- | ------------- 61 | 62 | **recursive** | **optional.Bool**| | [default to false] 63 | **nocache** | **optional.Bool**| | [default to false] 64 | 65 | ### Return type 66 | 67 | **string** 68 | 69 | ### Authorization 70 | 71 | No authorization required 72 | 73 | ### HTTP request headers 74 | 75 | - **Content-Type**: Not defined 76 | - **Accept**: application/json, */* 77 | 78 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 79 | 80 | -------------------------------------------------------------------------------- /packages/go-client/docs/Peer.md: -------------------------------------------------------------------------------- 1 | # Peer 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **string** | | 7 | **PublicKey** | **string** | | 8 | **Addresses** | [**Peers**](peers.md) | | 9 | **AgentVersion** | **string** | | 10 | **ProtocolVersion** | **string** | | 11 | **RepoVersion** | **float32** | | [optional] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/go-client/docs/Peers.md: -------------------------------------------------------------------------------- 1 | # Peers 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/Pin.md: -------------------------------------------------------------------------------- 1 | # Pin 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Cid** | **string** | | 7 | **Type** | **string** | | [default to all] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/go-client/docs/PingPeerPayload.md: -------------------------------------------------------------------------------- 1 | # PingPeerPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Count** | **float32** | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/go-client/docs/PingResponses.md: -------------------------------------------------------------------------------- 1 | # PingResponses 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/Pins.md: -------------------------------------------------------------------------------- 1 | # Pins 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/PinsApi.md: -------------------------------------------------------------------------------- 1 | # \PinsApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**PinAdd**](PinsApi.md#PinAdd) | **Post** /pins | Remove a hash from the pinset 8 | [**PinList**](PinsApi.md#PinList) | **Get** /pins | List all the objects pinned to local storage 9 | [**PinRemove**](PinsApi.md#PinRemove) | **Delete** /pins/{hash} | Remove a hash from the pinset 10 | 11 | 12 | # **PinAdd** 13 | > PinAdd(ctx, optional) 14 | Remove a hash from the pinset 15 | 16 | ### Required Parameters 17 | 18 | Name | Type | Description | Notes 19 | ------------- | ------------- | ------------- | ------------- 20 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 21 | **optional** | ***PinAddOpts** | optional parameters | nil if no parameters 22 | 23 | ### Optional Parameters 24 | Optional parameters are passed through a pointer to a PinAddOpts struct 25 | 26 | Name | Type | Description | Notes 27 | ------------- | ------------- | ------------- | ------------- 28 | **recursive** | **optional.Bool**| | [default to true] 29 | **createPinPayload** | [**optional.Interface of CreatePinPayload**](CreatePinPayload.md)| | 30 | 31 | ### Return type 32 | 33 | (empty response body) 34 | 35 | ### Authorization 36 | 37 | No authorization required 38 | 39 | ### HTTP request headers 40 | 41 | - **Content-Type**: Not defined 42 | - **Accept**: Not defined 43 | 44 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 45 | 46 | # **PinList** 47 | > Pins PinList(ctx, optional) 48 | List all the objects pinned to local storage 49 | 50 | ### Required Parameters 51 | 52 | Name | Type | Description | Notes 53 | ------------- | ------------- | ------------- | ------------- 54 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 55 | **optional** | ***PinListOpts** | optional parameters | nil if no parameters 56 | 57 | ### Optional Parameters 58 | Optional parameters are passed through a pointer to a PinListOpts struct 59 | 60 | Name | Type | Description | Notes 61 | ------------- | ------------- | ------------- | ------------- 62 | **type_** | **optional.String**| | [default to all] 63 | **cid** | **optional.String**| | 64 | **cidBase** | **optional.String**| Which number base to use when returning a CID | [default to base32] 65 | **cidVersion** | **optional.Int32**| Which CID version to use | [default to 1] 66 | 67 | ### Return type 68 | 69 | [**Pins**](pins.md) 70 | 71 | ### Authorization 72 | 73 | No authorization required 74 | 75 | ### HTTP request headers 76 | 77 | - **Content-Type**: Not defined 78 | - **Accept**: application/json, */* 79 | 80 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 81 | 82 | # **PinRemove** 83 | > PinRemove(ctx, hash, optional) 84 | Remove a hash from the pinset 85 | 86 | ### Required Parameters 87 | 88 | Name | Type | Description | Notes 89 | ------------- | ------------- | ------------- | ------------- 90 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 91 | **hash** | **string**| | 92 | **optional** | ***PinRemoveOpts** | optional parameters | nil if no parameters 93 | 94 | ### Optional Parameters 95 | Optional parameters are passed through a pointer to a PinRemoveOpts struct 96 | 97 | Name | Type | Description | Notes 98 | ------------- | ------------- | ------------- | ------------- 99 | 100 | **recursive** | **optional.Bool**| | [default to true] 101 | 102 | ### Return type 103 | 104 | (empty response body) 105 | 106 | ### Authorization 107 | 108 | No authorization required 109 | 110 | ### HTTP request headers 111 | 112 | - **Content-Type**: Not defined 113 | - **Accept**: Not defined 114 | 115 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 116 | 117 | -------------------------------------------------------------------------------- /packages/go-client/docs/Pong.md: -------------------------------------------------------------------------------- 1 | # Pong 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Success** | **bool** | | [optional] 7 | **Time** | **int32** | | [optional] 8 | **Text** | **string** | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/go-client/docs/PubsubApi.md: -------------------------------------------------------------------------------- 1 | # \PubsubApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**PubsubList**](PubsubApi.md#PubsubList) | **Get** /pubsub/topics | Returns the list of topics the peer is subscribed to 8 | [**PubsubSubscribe**](PubsubApi.md#PubsubSubscribe) | **Post** /pubsub/topics | Returns the list of topics the peer is subscribed to 9 | 10 | 11 | # **PubsubList** 12 | > string PubsubList(ctx, ) 13 | Returns the list of topics the peer is subscribed to 14 | 15 | ### Required Parameters 16 | This endpoint does not need any parameter. 17 | 18 | ### Return type 19 | 20 | **string** 21 | 22 | ### Authorization 23 | 24 | No authorization required 25 | 26 | ### HTTP request headers 27 | 28 | - **Content-Type**: Not defined 29 | - **Accept**: application/json, */* 30 | 31 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 32 | 33 | # **PubsubSubscribe** 34 | > string PubsubSubscribe(ctx, optional) 35 | Returns the list of topics the peer is subscribed to 36 | 37 | ### Required Parameters 38 | 39 | Name | Type | Description | Notes 40 | ------------- | ------------- | ------------- | ------------- 41 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 42 | **optional** | ***PubsubSubscribeOpts** | optional parameters | nil if no parameters 43 | 44 | ### Optional Parameters 45 | Optional parameters are passed through a pointer to a PubsubSubscribeOpts struct 46 | 47 | Name | Type | Description | Notes 48 | ------------- | ------------- | ------------- | ------------- 49 | **subscribeToPubsubTopicPayload** | [**optional.Interface of SubscribeToPubsubTopicPayload**](SubscribeToPubsubTopicPayload.md)| | 50 | 51 | ### Return type 52 | 53 | **string** 54 | 55 | ### Authorization 56 | 57 | No authorization required 58 | 59 | ### HTTP request headers 60 | 61 | - **Content-Type**: Not defined 62 | - **Accept**: application/json, */* 63 | 64 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 65 | 66 | -------------------------------------------------------------------------------- /packages/go-client/docs/RemotePeer.md: -------------------------------------------------------------------------------- 1 | # RemotePeer 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Id** | **string** | | 7 | **Address** | **string** | | 8 | **PublicKey** | **string** | | [optional] 9 | **Latency** | **string** | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/go-client/docs/RemotePeers.md: -------------------------------------------------------------------------------- 1 | # RemotePeers 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/docs/RenameKeypairPayload.md: -------------------------------------------------------------------------------- 1 | # RenameKeypairPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Name** | **string** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/go-client/docs/RepoApi.md: -------------------------------------------------------------------------------- 1 | # \RepoApi 2 | 3 | All URIs are relative to *http://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**RepoGc**](RepoApi.md#RepoGc) | **Post** /repo/gc | Perform a garbage collection sweep on the repo 8 | [**RepoStats**](RepoApi.md#RepoStats) | **Get** /repo | Get stats for the currently used repo 9 | 10 | 11 | # **RepoGc** 12 | > string RepoGc(ctx, ) 13 | Perform a garbage collection sweep on the repo 14 | 15 | ### Required Parameters 16 | This endpoint does not need any parameter. 17 | 18 | ### Return type 19 | 20 | **string** 21 | 22 | ### Authorization 23 | 24 | No authorization required 25 | 26 | ### HTTP request headers 27 | 28 | - **Content-Type**: Not defined 29 | - **Accept**: application/json, */* 30 | 31 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 32 | 33 | # **RepoStats** 34 | > RepoStats RepoStats(ctx, ) 35 | Get stats for the currently used repo 36 | 37 | ### Required Parameters 38 | This endpoint does not need any parameter. 39 | 40 | ### Return type 41 | 42 | [**RepoStats**](repo-stats.md) 43 | 44 | ### Authorization 45 | 46 | No authorization required 47 | 48 | ### HTTP request headers 49 | 50 | - **Content-Type**: Not defined 51 | - **Accept**: application/json, */* 52 | 53 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 54 | 55 | -------------------------------------------------------------------------------- /packages/go-client/docs/RepoStats.md: -------------------------------------------------------------------------------- 1 | # RepoStats 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **NumObjects** | **int32** | | [optional] 7 | **RepoSize** | **int32** | | [optional] 8 | **RepoPath** | **string** | | 9 | **Version** | **int32** | | [optional] 10 | **StorageMax** | **int32** | | [optional] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/go-client/docs/SubscribeToPubsubTopicPayload.md: -------------------------------------------------------------------------------- 1 | # SubscribeToPubsubTopicPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Topic** | **string** | | 7 | **Discover** | **bool** | | [optional] [default to false] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/go-client/docs/SwamConnectToPeerPayload.md: -------------------------------------------------------------------------------- 1 | # SwamConnectToPeerPayload 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Address** | **string** | | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/go-client/docs/UnixfsEntry.md: -------------------------------------------------------------------------------- 1 | # UnixfsEntry 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Cid** | **string** | | 7 | **Type** | **string** | | 8 | **CumulativeSize** | **int32** | | 9 | **Blocks** | **int32** | | 10 | **Size** | **int32** | | [optional] 11 | **WithLocality** | **bool** | | [optional] 12 | **Local** | **bool** | | [optional] 13 | **SizeLocal** | **int32** | | [optional] 14 | **Contents** | [**Contents**](contents.md) | | [optional] 15 | 16 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/go-client/docs/UnixfsEntrySummary.md: -------------------------------------------------------------------------------- 1 | # UnixfsEntrySummary 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Name** | **string** | | 7 | **Type** | **string** | | 8 | **Cid** | **string** | | 9 | **Size** | **int32** | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/go-client/docs/UpdateConfigBody.md: -------------------------------------------------------------------------------- 1 | # UpdateConfigBody 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/go-client/git_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="GIT_USER_ID" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="GIT_REPO_ID" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="Minor update" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /packages/go-client/model_bitswap_ledger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type BitswapLedger struct { 13 | Peer string `json:"peer,omitempty"` 14 | DebtRatio float32 `json:"debtRatio,omitempty"` 15 | Sent int32 `json:"sent,omitempty"` 16 | Received int32 `json:"received,omitempty"` 17 | Exchanges int32 `json:"exchanges,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /packages/go-client/model_bitswap_stats.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type BitswapStats struct { 13 | Blocks Blocks `json:"blocks,omitempty"` 14 | Data Blocks `json:"data,omitempty"` 15 | ProvideBufferLength int32 `json:"provideBufferLength,omitempty"` 16 | Peers Peers `json:"peers,omitempty"` 17 | Wantlist Peers `json:"wantlist,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /packages/go-client/model_blocks.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Blocks struct { 13 | Sent int32 `json:"sent,omitempty"` 14 | Received int32 `json:"received,omitempty"` 15 | Duplicate int32 `json:"duplicate,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /packages/go-client/model_cid_list.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | // The content IDs you are announcing 13 | type CidList struct { 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_contents.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Contents struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_create_pin_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type CreatePinPayload struct { 13 | Hash string `json:"hash"` 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_dag_link.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DagLink struct { 13 | Name string `json:"name,omitempty"` 14 | Size int32 `json:"size,omitempty"` 15 | Cid string `json:"cid"` 16 | } 17 | -------------------------------------------------------------------------------- /packages/go-client/model_dag_node.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DagNode struct { 13 | Data string `json:"data,omitempty"` 14 | Links Links `json:"links,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-client/model_dht_value.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DhtValue struct { 13 | Value string `json:"value"` 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_generate_keypair_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type GenerateKeypairPayload struct { 13 | Name string `json:"name"` 14 | // base64 encoded PKCS #8 PEM file to import keypairs from 15 | Pem string `json:"pem,omitempty"` 16 | // Password to PKCS #8 PEM file 17 | Password string `json:"password,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /packages/go-client/model_ipns_options.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type IpnsOptions struct { 13 | Value string `json:"value"` 14 | // Resolve given path before publishing 15 | Resolve bool `json:"resolve,omitempty"` 16 | // Time duration of the record 17 | Lifetime string `json:"lifetime,omitempty"` 18 | // Time duration this record should be cached 19 | Ttl string `json:"ttl,omitempty"` 20 | // Name of the key to be used or Peer ID 21 | Key string `json:"key,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /packages/go-client/model_ipns_record.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type IpnsRecord struct { 13 | Name string `json:"name,omitempty"` 14 | Value string `json:"value,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-client/model_links.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Links struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Peer struct { 13 | Id string `json:"id"` 14 | PublicKey string `json:"publicKey"` 15 | Addresses Peers `json:"addresses"` 16 | AgentVersion string `json:"agentVersion"` 17 | ProtocolVersion string `json:"protocolVersion"` 18 | RepoVersion float32 `json:"repoVersion,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /packages/go-client/model_peers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Peers struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_pin.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pin struct { 13 | Cid string `json:"cid"` 14 | Type string `json:"type"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-client/model_ping_peer_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type PingPeerPayload struct { 13 | Count float32 `json:"count,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_ping_responses.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type PingResponses struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_pins.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pins struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_pong.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pong struct { 13 | Success bool `json:"success,omitempty"` 14 | Time int32 `json:"time,omitempty"` 15 | Text string `json:"text,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /packages/go-client/model_remote_peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RemotePeer struct { 13 | Id string `json:"id"` 14 | Address string `json:"address"` 15 | PublicKey string `json:"publicKey,omitempty"` 16 | Latency string `json:"latency,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-client/model_remote_peers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RemotePeers struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/model_rename_keypair_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RenameKeypairPayload struct { 13 | Name string `json:"name"` 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_repo_stats.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RepoStats struct { 13 | NumObjects int32 `json:"numObjects,omitempty"` 14 | RepoSize int32 `json:"repoSize,omitempty"` 15 | RepoPath string `json:"repoPath"` 16 | Version int32 `json:"version,omitempty"` 17 | StorageMax int32 `json:"storageMax,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /packages/go-client/model_subscribe_to_pubsub_topic_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type SubscribeToPubsubTopicPayload struct { 13 | Topic string `json:"topic"` 14 | Discover bool `json:"discover,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-client/model_swam_connect_to_peer_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type SwamConnectToPeerPayload struct { 13 | Address string `json:"address"` 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-client/model_unixfs_entry.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UnixfsEntry struct { 13 | Cid string `json:"cid"` 14 | Type string `json:"type"` 15 | CumulativeSize int32 `json:"cumulativeSize"` 16 | Blocks int32 `json:"blocks"` 17 | Size int32 `json:"size,omitempty"` 18 | WithLocality bool `json:"withLocality,omitempty"` 19 | Local bool `json:"local,omitempty"` 20 | SizeLocal int32 `json:"sizeLocal,omitempty"` 21 | Contents Contents `json:"contents,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /packages/go-client/model_unixfs_entry_summary.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UnixfsEntrySummary struct { 13 | Name string `json:"name"` 14 | Type string `json:"type"` 15 | Cid string `json:"cid"` 16 | Size int32 `json:"size,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-client/model_update_config_body.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UpdateConfigBody struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-client/response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | type APIResponse struct { 17 | *http.Response `json:"-"` 18 | Message string `json:"message,omitempty"` 19 | // Operation is the name of the OpenAPI operation. 20 | Operation string `json:"operation,omitempty"` 21 | // RequestURL is the request URL. This value is always available, even if the 22 | // embedded *http.Response is nil. 23 | RequestURL string `json:"url,omitempty"` 24 | // Method is the HTTP method used for the request. This value is always 25 | // available, even if the embedded *http.Response is nil. 26 | Method string `json:"method,omitempty"` 27 | // Payload holds the contents of the response body (which may be nil or empty). 28 | // This is provided here as the raw response.Body() reader will have already 29 | // been drained. 30 | Payload []byte `json:"-"` 31 | } 32 | 33 | func NewAPIResponse(r *http.Response) *APIResponse { 34 | 35 | response := &APIResponse{Response: r} 36 | return response 37 | } 38 | 39 | func NewAPIResponseWithError(errorMessage string) *APIResponse { 40 | 41 | response := &APIResponse{Message: errorMessage} 42 | return response 43 | } 44 | -------------------------------------------------------------------------------- /packages/go-server/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /packages/go-server/.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 3.2.3 -------------------------------------------------------------------------------- /packages/go-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.10 AS build 2 | WORKDIR /go/src 3 | COPY go ./go 4 | COPY main.go . 5 | 6 | ENV CGO_ENABLED=0 7 | RUN go get -d -v ./... 8 | 9 | RUN go build -a -installsuffix cgo -o openapi . 10 | 11 | FROM scratch AS runtime 12 | COPY --from=build /go/src/openapi ./ 13 | EXPOSE 8080/tcp 14 | ENTRYPOINT ["./openapi"] 15 | -------------------------------------------------------------------------------- /packages/go-server/go/README.md: -------------------------------------------------------------------------------- 1 | # Go API Server for openapi 2 | 3 | No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 4 | 5 | ## Overview 6 | This server was generated by the [openapi-generator] 7 | (https://openapi-generator.tech) project. 8 | By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. 9 | - 10 | 11 | To see how to make this your own, look here: 12 | 13 | [README]((https://openapi-generator.tech)) 14 | 15 | - API version: 1.0.0 16 | - Build date: 2018-09-12T16:15:08.162+01:00[Europe/London] 17 | 18 | 19 | ### Running the server 20 | To run the server, follow these simple steps: 21 | 22 | ``` 23 | go run main.go 24 | ``` 25 | 26 | To run the server in a docker container 27 | ``` 28 | docker build --network=host -t openapi . 29 | ``` 30 | 31 | Once image is built use 32 | ``` 33 | docker run --rm -it openapi 34 | ``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/go-server/go/api_bitswap.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // BitswapLedger - Show the current ledger for a peer 17 | func BitswapLedger(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // BitswapReprovide - Trigger reprovider 23 | func BitswapReprovide(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // BitswapStats - Show diagnostic information on the bitswap agent 29 | func BitswapStats(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // BitswapUnwant - Remove a given block from your wantlist 35 | func BitswapUnwant(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | 40 | // BitswapWantlist - Show blocks currently on the wantlist 41 | func BitswapWantlist(w http.ResponseWriter, r *http.Request) { 42 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 43 | w.WriteHeader(http.StatusOK) 44 | } 45 | -------------------------------------------------------------------------------- /packages/go-server/go/api_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // ConfigGet - Returns the current config 17 | func ConfigGet(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // ConfigPatch - Replaces part of the current config 23 | func ConfigPatch(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // ConfigReplace - Replaces the current config 29 | func ConfigReplace(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // ConfigReset - Resets the current config to default values 35 | func ConfigReset(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | -------------------------------------------------------------------------------- /packages/go-server/go/api_dag.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // DagCreate - Store an IPLD format node 17 | func DagCreate(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // DagGet - Get a DAG node 23 | func DagGet(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // DagRemove - Remove a DAG node from your local repo 29 | func DagRemove(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // DagUpdate - Update an IPLD format node 35 | func DagUpdate(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | -------------------------------------------------------------------------------- /packages/go-server/go/api_dht.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // DhtFindPeer - Retrieve the Peer Info of a reachable node in the network 17 | func DhtFindPeer(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // DhtFindProviders - Retrieve the providers for content that is addressed by an hash 23 | func DhtFindProviders(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // DhtGet - Retrieve a value from the DHT 29 | func DhtGet(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // DhtProvide - Announce to the network that you are providing given values 35 | func DhtProvide(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | 40 | // DhtPut - Store a value on the DHT 41 | func DhtPut(w http.ResponseWriter, r *http.Request) { 42 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 43 | w.WriteHeader(http.StatusOK) 44 | } 45 | 46 | // DhtQuery - Queries the network for the 'closest peers' to a given key 47 | func DhtQuery(w http.ResponseWriter, r *http.Request) { 48 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 49 | w.WriteHeader(http.StatusOK) 50 | } 51 | -------------------------------------------------------------------------------- /packages/go-server/go/api_dns.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // MiscellaneousDns - Resolve DNS links 17 | func MiscellaneousDns(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | -------------------------------------------------------------------------------- /packages/go-server/go/api_files.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // FilesCreate - Create an MFS path 17 | func FilesCreate(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // FilesGet - Get a file or directory from your MFS 23 | func FilesGet(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // FilesRemove - Remove an MFS path 29 | func FilesRemove(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // FilesReplace - Update an MFS path 35 | func FilesReplace(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | 40 | // FilesUpdate - Update an MFS path 41 | func FilesUpdate(w http.ResponseWriter, r *http.Request) { 42 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 43 | w.WriteHeader(http.StatusOK) 44 | } 45 | -------------------------------------------------------------------------------- /packages/go-server/go/api_key.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // KeyGenerate - Create a new keypair 17 | func KeyGenerate(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // KeyList - List all local keypairs 23 | func KeyList(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // KeyRemove - Remove a keypair 29 | func KeyRemove(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // KeyRename - Rename a keypair 35 | func KeyRename(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | -------------------------------------------------------------------------------- /packages/go-server/go/api_name.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // NamePublish - Publish an IPNS name with a given value 17 | func NamePublish(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // NameResolve - Resolve an IPNS name 23 | func NameResolve(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | -------------------------------------------------------------------------------- /packages/go-server/go/api_pins.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // PinAdd - Remove a hash from the pinset 17 | func PinAdd(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // PinList - List all the objects pinned to local storage 23 | func PinList(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // PinRemove - Remove a hash from the pinset 29 | func PinRemove(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | -------------------------------------------------------------------------------- /packages/go-server/go/api_pubsub.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // PubsubList - Returns the list of topics the peer is subscribed to 17 | func PubsubList(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // PubsubSubscribe - Returns the list of topics the peer is subscribed to 23 | func PubsubSubscribe(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | -------------------------------------------------------------------------------- /packages/go-server/go/api_repo.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // RepoGc - Perform a garbage collection sweep on the repo 17 | func RepoGc(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // RepoStats - Get stats for the currently used repo 23 | func RepoStats(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | -------------------------------------------------------------------------------- /packages/go-server/go/api_swarm.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // SwarmAddrs - List of known addresses of each peer connected 17 | func SwarmAddrs(w http.ResponseWriter, r *http.Request) { 18 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 19 | w.WriteHeader(http.StatusOK) 20 | } 21 | 22 | // SwarmConnect - Open a connection to a given address 23 | func SwarmConnect(w http.ResponseWriter, r *http.Request) { 24 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 25 | w.WriteHeader(http.StatusOK) 26 | } 27 | 28 | // SwarmDisconnect - Close a connection to a given address 29 | func SwarmDisconnect(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 31 | w.WriteHeader(http.StatusOK) 32 | } 33 | 34 | // SwarmInfo - Returns information about this peer 35 | func SwarmInfo(w http.ResponseWriter, r *http.Request) { 36 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 37 | w.WriteHeader(http.StatusOK) 38 | } 39 | 40 | // SwarmPeers - List out the peers that we have connections with 41 | func SwarmPeers(w http.ResponseWriter, r *http.Request) { 42 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 43 | w.WriteHeader(http.StatusOK) 44 | } 45 | 46 | // SwarmPing - Send echo request packets to IPFS hosts 47 | func SwarmPing(w http.ResponseWriter, r *http.Request) { 48 | w.Header().Set("Content-Type", "application/json; charset=UTF-8") 49 | w.WriteHeader(http.StatusOK) 50 | } 51 | -------------------------------------------------------------------------------- /packages/go-server/go/logger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | import ( 13 | "log" 14 | "net/http" 15 | "time" 16 | ) 17 | 18 | func Logger(inner http.Handler, name string) http.Handler { 19 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 20 | start := time.Now() 21 | 22 | inner.ServeHTTP(w, r) 23 | 24 | log.Printf( 25 | "%s %s %s %s", 26 | r.Method, 27 | r.RequestURI, 28 | name, 29 | time.Since(start), 30 | ) 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /packages/go-server/go/model_bitswap_ledger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type BitswapLedger struct { 13 | 14 | Peer string `json:"peer,omitempty"` 15 | 16 | DebtRatio float32 `json:"debtRatio,omitempty"` 17 | 18 | Sent int32 `json:"sent,omitempty"` 19 | 20 | Received int32 `json:"received,omitempty"` 21 | 22 | Exchanges int32 `json:"exchanges,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /packages/go-server/go/model_bitswap_stats.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type BitswapStats struct { 13 | 14 | Blocks *Blocks `json:"blocks,omitempty"` 15 | 16 | Data *Blocks `json:"data,omitempty"` 17 | 18 | ProvideBufferLength int32 `json:"provideBufferLength,omitempty"` 19 | 20 | Peers *Peers `json:"peers,omitempty"` 21 | 22 | Wantlist *Peers `json:"wantlist,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /packages/go-server/go/model_blocks.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Blocks struct { 13 | 14 | Sent int32 `json:"sent,omitempty"` 15 | 16 | Received int32 `json:"received,omitempty"` 17 | 18 | Duplicate int32 `json:"duplicate,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /packages/go-server/go/model_cid_list.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | // CidList - The content IDs you are announcing 13 | type CidList struct { 14 | } 15 | -------------------------------------------------------------------------------- /packages/go-server/go/model_contents.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Contents struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_create_pin_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type CreatePinPayload struct { 13 | 14 | Hash string `json:"hash"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-server/go/model_dag_link.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DagLink struct { 13 | 14 | Name string `json:"name,omitempty"` 15 | 16 | Size int32 `json:"size,omitempty"` 17 | 18 | Cid string `json:"cid"` 19 | } 20 | -------------------------------------------------------------------------------- /packages/go-server/go/model_dag_node.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DagNode struct { 13 | 14 | Data string `json:"data,omitempty"` 15 | 16 | Links *Links `json:"links,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-server/go/model_dht_value.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type DhtValue struct { 13 | 14 | Value string `json:"value"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-server/go/model_generate_keypair_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type GenerateKeypairPayload struct { 13 | 14 | Name string `json:"name"` 15 | 16 | // base64 encoded PKCS #8 PEM file to import keypairs from 17 | Pem string `json:"pem,omitempty"` 18 | 19 | // Password to PKCS #8 PEM file 20 | Password string `json:"password,omitempty"` 21 | } 22 | -------------------------------------------------------------------------------- /packages/go-server/go/model_ipns_options.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type IpnsOptions struct { 13 | 14 | Value string `json:"value"` 15 | 16 | // Resolve given path before publishing 17 | Resolve bool `json:"resolve,omitempty"` 18 | 19 | // Time duration of the record 20 | Lifetime string `json:"lifetime,omitempty"` 21 | 22 | // Time duration this record should be cached 23 | Ttl string `json:"ttl,omitempty"` 24 | 25 | // Name of the key to be used or Peer ID 26 | Key string `json:"key,omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /packages/go-server/go/model_ipns_record.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type IpnsRecord struct { 13 | 14 | Name string `json:"name,omitempty"` 15 | 16 | Value string `json:"value,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-server/go/model_links.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Links struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Peer struct { 13 | 14 | Id string `json:"id"` 15 | 16 | PublicKey string `json:"publicKey"` 17 | 18 | Addresses *Peers `json:"addresses"` 19 | 20 | AgentVersion string `json:"agentVersion"` 21 | 22 | ProtocolVersion string `json:"protocolVersion"` 23 | 24 | RepoVersion float32 `json:"repoVersion,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /packages/go-server/go/model_peers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Peers struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_pin.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pin struct { 13 | 14 | Cid string `json:"cid"` 15 | 16 | Type string `json:"type"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-server/go/model_ping_peer_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type PingPeerPayload struct { 13 | 14 | Count float32 `json:"count,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-server/go/model_ping_responses.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type PingResponses struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_pins.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pins struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_pong.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type Pong struct { 13 | 14 | Success bool `json:"success,omitempty"` 15 | 16 | Time int32 `json:"time,omitempty"` 17 | 18 | Text string `json:"text,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /packages/go-server/go/model_remote_peer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RemotePeer struct { 13 | 14 | Id string `json:"id"` 15 | 16 | Address string `json:"address"` 17 | 18 | PublicKey string `json:"publicKey,omitempty"` 19 | 20 | Latency string `json:"latency,omitempty"` 21 | } 22 | -------------------------------------------------------------------------------- /packages/go-server/go/model_remote_peers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RemotePeers struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/go/model_rename_keypair_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RenameKeypairPayload struct { 13 | 14 | Name string `json:"name"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-server/go/model_repo_stats.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type RepoStats struct { 13 | 14 | NumObjects int32 `json:"numObjects,omitempty"` 15 | 16 | RepoSize int32 `json:"repoSize,omitempty"` 17 | 18 | RepoPath string `json:"repoPath"` 19 | 20 | Version int32 `json:"version,omitempty"` 21 | 22 | StorageMax int32 `json:"storageMax,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /packages/go-server/go/model_subscribe_to_pubsub_topic_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type SubscribeToPubsubTopicPayload struct { 13 | 14 | Topic string `json:"topic"` 15 | 16 | Discover bool `json:"discover,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /packages/go-server/go/model_swam_connect_to_peer_payload.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type SwamConnectToPeerPayload struct { 13 | 14 | Address string `json:"address"` 15 | } 16 | -------------------------------------------------------------------------------- /packages/go-server/go/model_unixfs_entry.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UnixfsEntry struct { 13 | 14 | Cid string `json:"cid"` 15 | 16 | Type string `json:"type"` 17 | 18 | CumulativeSize int32 `json:"cumulativeSize"` 19 | 20 | Blocks int32 `json:"blocks"` 21 | 22 | Size int32 `json:"size,omitempty"` 23 | 24 | WithLocality bool `json:"withLocality,omitempty"` 25 | 26 | Local bool `json:"local,omitempty"` 27 | 28 | SizeLocal int32 `json:"sizeLocal,omitempty"` 29 | 30 | Contents *Contents `json:"contents,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /packages/go-server/go/model_unixfs_entry_summary.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UnixfsEntrySummary struct { 13 | 14 | Name string `json:"name"` 15 | 16 | Type string `json:"type"` 17 | 18 | Cid string `json:"cid"` 19 | 20 | Size int32 `json:"size,omitempty"` 21 | } 22 | -------------------------------------------------------------------------------- /packages/go-server/go/model_update_config_body.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package openapi 11 | 12 | type UpdateConfigBody struct { 13 | } 14 | -------------------------------------------------------------------------------- /packages/go-server/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * IPFS API Documentation 3 | * 4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech) 8 | */ 9 | 10 | package main 11 | 12 | import ( 13 | "log" 14 | "net/http" 15 | 16 | // WARNING! 17 | // Change this to a fully-qualified import path 18 | // once you place this file into your project. 19 | // For example, 20 | // 21 | // sw "github.com/myname/myrepo/go" 22 | // 23 | sw "./go" 24 | ) 25 | 26 | func main() { 27 | log.Printf("Server started") 28 | 29 | router := sw.NewRouter() 30 | 31 | log.Fatal(http.ListenAndServe(":8080", router)) 32 | } 33 | -------------------------------------------------------------------------------- /packages/js-graphql-server/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const pkg = require('./package.json') 4 | const { ApolloServer } = require('apollo-server-hapi') 5 | 6 | const schema = require('./schema') 7 | const resolvers = require('./resolvers') 8 | 9 | module.exports = { 10 | register: async (server, options) => { 11 | const apollo = new ApolloServer({ 12 | typeDefs: [ 13 | schema 14 | ], 15 | resolvers: resolvers(), 16 | tracing: true 17 | }) 18 | 19 | await apollo.applyMiddleware({ 20 | app: server 21 | }) 22 | 23 | await apollo.installSubscriptionHandlers(server.listener) 24 | }, 25 | version: pkg.version, 26 | name: pkg.name 27 | } 28 | -------------------------------------------------------------------------------- /packages/js-graphql-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipfs-graphql-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "reset": "rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "apollo-server-hapi": "^2.0.5", 14 | "boom": "^7.2.0", 15 | "graphql": "^14.0.0", 16 | "ipfs-rest-client": "^1.0.0" 17 | }, 18 | "devDependencies": { 19 | "aegir": "^15.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/js-graphql-server/resolvers/client.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const SwaggerClient = require('swagger-client') 4 | 5 | let client 6 | 7 | module.exports = () => { 8 | if (!client) { 9 | client = new SwaggerClient(`http://localhost:${process.env.PORT}/swagger.json`) 10 | } 11 | 12 | return client 13 | } 14 | -------------------------------------------------------------------------------- /packages/js-graphql-server/resolvers/dag.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const client = require('./client') 4 | 5 | module.exports = { 6 | Query: { 7 | dagGet: async (root, { cid, cidBase = 'base58btc', cidVersion = 0 }) => { 8 | const ipfs = await client() 9 | console.info(ipfs) 10 | return ipfs 11 | .apis 12 | .dag 13 | .get({ 14 | cid, 15 | cidBase, 16 | cidVersion, 17 | headers: { 18 | accept: 'application/json' 19 | } 20 | }) 21 | .then(result => result.obj) 22 | } 23 | }, 24 | 25 | Mutation: { 26 | dagCreate: (root, { data }) => { 27 | 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/js-graphql-server/resolvers/files.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | Query: { 5 | filesList: (root, { path }) => { 6 | 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/js-graphql-server/resolvers/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const dag = require('./dag') 4 | const files = require('./files') 5 | 6 | module.exports = (models) => { 7 | return { 8 | Query: { 9 | ...dag.Query, 10 | ...files.Query 11 | }, 12 | Mutation: {} 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/js-graphql-server/schema/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = ` 4 | type DagNode { 5 | cid: String!, 6 | size: Int, 7 | links: [DagLink] 8 | } 9 | 10 | type DagLink { 11 | cid: String!, 12 | name: String, 13 | size: Int, 14 | } 15 | 16 | type FileNode { 17 | cid: String! 18 | } 19 | 20 | type Query { 21 | dagGet(cid: String!, cidBase: String, cidVersion: Int): DagNode 22 | filesList(path: String!): FileNode 23 | } 24 | 25 | type Mutation { 26 | dagCreate(data: String!): DagNode 27 | } 28 | 29 | schema { 30 | query: Query 31 | mutation: Mutation 32 | } 33 | ` 34 | -------------------------------------------------------------------------------- /packages/js-http-server/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.on('unhandledRejection', (error) => { 4 | throw error 5 | }) 6 | 7 | const createServer = require('./server') 8 | 9 | const startServer = async function () { 10 | try { 11 | const server = await createServer() 12 | await server.start() 13 | console.log('Server running at:', server.info.uri) 14 | } catch (error) { 15 | console.error(error) 16 | process.exit(1) 17 | } 18 | } 19 | 20 | startServer() 21 | -------------------------------------------------------------------------------- /packages/js-http-server/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "PORT": 8000 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/js-http-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipfs-http-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon --watch ../js-graphql-server --watch ../js-rest-server --watch . .", 9 | "reset": "rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules" 10 | }, 11 | "author": "", 12 | "license": "MIT", 13 | "dependencies": { 14 | "glue": "^5.0.0", 15 | "ipfs-rest-server": "^1.0.0", 16 | "ipfs-graphql-server": "^1.0.0" 17 | }, 18 | "devDependencies": { 19 | "aegir": "^15.1.0", 20 | "nodemon": "^1.18.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/js-http-server/server.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Glue = require('glue') 4 | const manifest = { 5 | server: { 6 | host: 'localhost', 7 | port: process.env.PORT, 8 | debug: { request: ['error'] } 9 | }, 10 | register: { 11 | plugins: [ 12 | require('ipfs-rest-server'), 13 | require('ipfs-graphql-server') 14 | ], 15 | options: { 16 | once: true 17 | } 18 | } 19 | } 20 | 21 | const options = { 22 | relativeTo: __dirname 23 | } 24 | 25 | module.exports = async () => { 26 | return await Glue.compose(manifest, options) 27 | } 28 | -------------------------------------------------------------------------------- /packages/js-rest-client/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const SwaggerClient = require('swagger-client') 4 | 5 | module.exports = (url) => { 6 | return new SwaggerClient(url) 7 | } 8 | -------------------------------------------------------------------------------- /packages/js-rest-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipfs-rest-client", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "reset": "rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "swagger-client": "^3.8.15" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/js-rest-server/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const pkg = require('./package.json') 4 | const HapiSwagger = require('hapi-swagger') 5 | const routes = require('./routes') 6 | const IPFS = require('ipfs') 7 | const remote = require('ipfs-api') 8 | const Inert = require('inert') 9 | const Vision = require('vision') 10 | const log = require('debug')('ipfs:http:server') 11 | 12 | const getIpfs = async (options) => { 13 | if (options.ipfs) { 14 | log('Using pre-configured IPFS instance') 15 | return options.ipfs 16 | } 17 | 18 | if (options.host && options.port) { 19 | log(`Connecting to remote IPFS at ${options.host}:${options.port}`) 20 | return remote(options.host, options.port) 21 | } 22 | 23 | return new Promise((resolve, reject) => { 24 | log(`Starting an IPFS instance`) 25 | 26 | const ipfs = new IPFS({ 27 | EXPERIMENTAL: { 28 | pubsub: true 29 | } 30 | }) 31 | ipfs.once('ready', () => resolve(ipfs)) 32 | ipfs.once('error', (error) => reject(error)) 33 | }) 34 | } 35 | 36 | module.exports = { 37 | register: async (server, options) => { 38 | server.app.ipfs = await getIpfs(options) 39 | 40 | await server.register([ 41 | Inert, 42 | Vision, { 43 | plugin: HapiSwagger, 44 | options: { 45 | info: { 46 | title: 'IPFS API Documentation', 47 | version: pkg.version, 48 | }, 49 | sortTags: 'name', 50 | sortEndpoints: 'path', 51 | definitionPrefix: 'useLabel', 52 | jsonEditor: true 53 | } 54 | }]) 55 | 56 | server.route(routes) 57 | }, 58 | version: pkg.version, 59 | name: pkg.name 60 | } 61 | -------------------------------------------------------------------------------- /packages/js-rest-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ipfs-rest-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "reset": "rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "async": "^2.6.1", 14 | "boom": "^7.2.0", 15 | "cids": "~0.5.3", 16 | "hapi-swagger": "achingbrain/hapi-swagger#remove-type-from-arrays-with-item-ref", 17 | "inert": "^5.1.0", 18 | "ipfs": "~0.31.7", 19 | "multihashes": "~0.4.14", 20 | "vision": "^5.3.3" 21 | }, 22 | "devDependencies": { 23 | "aegir": "^15.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./ledger'), 5 | require('./reprovide'), 6 | require('./stats'), 7 | require('./unwant'), 8 | require('./wantlist') 9 | ] 10 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/ledger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi, 10 | cidVersion, 11 | cidBase 12 | } = require('../../utils/validation') 13 | const transformHash = require('../../utils/transform-hash') 14 | 15 | module.exports = { 16 | method: 'GET', 17 | path: '/bitswap/ledger/{peerId}', 18 | options: { 19 | handler: (request, reply) => { 20 | return request.server.app.ipfs.bitswap.ledger(request.params.peerId) 21 | }, 22 | description: 'Show the current ledger for a peer', 23 | tags: ['api'], 24 | validate: { 25 | params: { 26 | peerId: Joi 27 | .peerId() 28 | .required() 29 | }, 30 | query: { 31 | cidBase, 32 | cidVersion 33 | }, 34 | headers: { 35 | accept: Joi.string() 36 | .default(JSON) 37 | .valid([ 38 | JSON, 39 | EVERYTHING 40 | ]) 41 | }, 42 | options: { 43 | allowUnknown: true 44 | } 45 | }, 46 | response: { 47 | status: { 48 | 200: Joi.object({ 49 | peer: Joi.string(), 50 | debtRatio: Joi.number(), 51 | sent: Joi 52 | .number() 53 | .integer() 54 | .min(0) 55 | .unit('bytes'), 56 | received: Joi 57 | .number() 58 | .integer() 59 | .min(0) 60 | .unit('bytes'), 61 | exchanges: Joi 62 | .number() 63 | .integer() 64 | .min(0) 65 | }).label('bitswap-ledger') 66 | } 67 | }, 68 | plugins: { 69 | 'hapi-swagger': { 70 | id: 'bitswap.ledger', 71 | responses: { 72 | 404: { 73 | description: 'The peer id was not found' 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/reprovide.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | const CID = require('cids') 5 | const { 6 | JSON, 7 | OCTET_STREAM, 8 | EVERYTHING 9 | } = require('../../utils/mime-types') 10 | const cidVersion = require('../../utils/validation/cid-version') 11 | const cidBase = require('../../utils/validation/cid-base') 12 | const transformHash = require('../../utils/transform-hash') 13 | 14 | module.exports = { 15 | method: 'POST', 16 | path: '/bitswap/reprovide', 17 | options: { 18 | handler: (request, reply) => { 19 | return request.server.app.ipfs.bitswap.reprovide() 20 | .then(() => reply.response().code(204)) 21 | }, 22 | description: 'Trigger reprovider', 23 | tags: ['api'], 24 | validate: { 25 | options: { 26 | allowUnknown: true 27 | } 28 | }, 29 | response: { 30 | status: { 31 | 204: Joi.empty() 32 | } 33 | }, 34 | plugins: { 35 | 'hapi-swagger': { 36 | id: 'bitswap.reprovide' 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/stats.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | const CID = require('cids') 5 | const mh = require('multihashes') 6 | const { 7 | JSON, 8 | OCTET_STREAM, 9 | EVERYTHING 10 | } = require('../../utils/mime-types') 11 | const cidVersion = require('../../utils/validation/cid-version') 12 | const cidBase = require('../../utils/validation/cid-base') 13 | const transformHash = require('../../utils/transform-hash') 14 | 15 | module.exports = { 16 | method: 'GET', 17 | path: '/bitswap/stats', 18 | options: { 19 | handler: (request, reply) => { 20 | return request.server.app.ipfs.bitswap.stat() 21 | .then(result => { 22 | return { 23 | blocks: { 24 | sent: Number(result.blocksSent), 25 | received: Number(result.blocksReceived), 26 | duplicate: Number(result.dupBlksReceived) 27 | }, 28 | data: { 29 | sent: Number(result.dataSent), 30 | received: Number(result.dataReceived), 31 | duplicate: Number(result.dupDataReceived) 32 | }, 33 | peers: result.peers.map(hash => transformHash(hash, 0, 'base58btc')), 34 | wantlist: result.wantlist.map(hash => transformHash(hash, request.query.cidVersion, request.query.cidBase)), 35 | provideBufferLength: Number(result.provideBufLen) 36 | } 37 | }) 38 | }, 39 | description: 'Show diagnostic information on the bitswap agent', 40 | tags: ['api'], 41 | validate: { 42 | query: { 43 | cidBase, 44 | cidVersion 45 | }, 46 | headers: { 47 | accept: Joi.string() 48 | .default(JSON) 49 | .valid([ 50 | JSON, 51 | EVERYTHING 52 | ]) 53 | }, 54 | options: { 55 | allowUnknown: true 56 | } 57 | }, 58 | response: { 59 | status: { 60 | 200: Joi.object({ 61 | blocks: Joi.object({ 62 | sent: Joi 63 | .number() 64 | .integer() 65 | .min(0), 66 | received: Joi 67 | .number() 68 | .integer() 69 | .min(0), 70 | duplicate: Joi 71 | .number() 72 | .integer() 73 | .min(0) 74 | }), 75 | data: Joi.object({ 76 | sent: Joi 77 | .number() 78 | .integer() 79 | .min(0) 80 | .unit('bytes'), 81 | received: Joi 82 | .number() 83 | .integer() 84 | .min(0) 85 | .unit('bytes'), 86 | duplicate: Joi 87 | .number() 88 | .integer() 89 | .min(0) 90 | .unit('bytes') 91 | }), 92 | provideBufferLength: Joi 93 | .number() 94 | .integer() 95 | .min(0), 96 | peers: Joi 97 | .array() 98 | .items(Joi.string().label('cid')), 99 | wantlist: Joi 100 | .array() 101 | .items(Joi.string().label('cid')) 102 | }).label('bitswap-stats') 103 | } 104 | }, 105 | plugins: { 106 | 'hapi-swagger': { 107 | id: 'bitswap.stats' 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/unwant.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const CID = require('cids') 4 | const { 5 | Joi, 6 | cidVersion, 7 | cidBase 8 | } = require('../../utils/validation') 9 | const { 10 | JSON, 11 | OCTET_STREAM, 12 | EVERYTHING 13 | } = require('../../utils/mime-types') 14 | const transformHash = require('../../utils/transform-hash') 15 | 16 | module.exports = { 17 | method: 'DELETE', 18 | path: '/bitswap/wantlist/{cid}', 19 | options: { 20 | handler: (request, reply) => { 21 | return request.server.app.ipfs.bitswap.unwant(request.params.cid) 22 | .then(() => reply.response().code(204)) 23 | }, 24 | description: 'Remove a given block from your wantlist', 25 | tags: ['api'], 26 | validate: { 27 | params: { 28 | cid: Joi 29 | .cid() 30 | .required() 31 | .description('The CID to remove from the wantlist') 32 | }, 33 | options: { 34 | allowUnknown: true 35 | } 36 | }, 37 | plugins: { 38 | 'hapi-swagger': { 39 | id: 'bitswap.unwant', 40 | responses: { 41 | 204: { 42 | description: 'The block was removed from your wantlist' 43 | }, 44 | 404: { 45 | description: 'The block was not in your wantlist' 46 | } 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/bitswap/wantlist.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi, 10 | cidVersion, 11 | cidBase 12 | } = require('../../utils/validation') 13 | const transformHash = require('../../utils/transform-hash') 14 | 15 | module.exports = { 16 | method: 'GET', 17 | path: '/bitswap/wantlist', 18 | options: { 19 | handler: (request, reply) => { 20 | console.info('request.query.peerId', request.query.peerId) 21 | return request.server.app.ipfs.bitswap.wantlist(request.query.peerId) 22 | .then(wantlist => { 23 | console.info(wantlist) 24 | if (wantlist && wantlist.Keys) { 25 | return wantlist.Keys.map(hash => transformHash(hash, request.query.cidVersion, request.query.cidBase)) 26 | } 27 | 28 | return [] 29 | }) 30 | }, 31 | description: 'Show blocks currently on the wantlist', 32 | tags: ['api'], 33 | validate: { 34 | query: { 35 | cidBase, 36 | cidVersion, 37 | peerId: Joi 38 | .peerId() 39 | .description('Filter the wantlist by this peer ID') 40 | }, 41 | headers: { 42 | accept: Joi.string() 43 | .valid([ 44 | JSON, 45 | EVERYTHING 46 | ]) 47 | }, 48 | options: { 49 | allowUnknown: true 50 | } 51 | }, 52 | response: { 53 | status: { 54 | 200: Joi 55 | .array() 56 | .items(Joi.string().label('cid')) 57 | } 58 | }, 59 | plugins: { 60 | 'hapi-swagger': { 61 | id: 'bitswap.wantlist' 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/config/get.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi 5 | } = require('../../utils/validation') 6 | 7 | module.exports = { 8 | method: 'GET', 9 | path: '/config', 10 | options: { 11 | handler: (request, reply) => { 12 | return request.server.app.ipfs.config.get() 13 | }, 14 | description: 'Returns the current config', 15 | tags: ['api'], 16 | plugins: { 17 | 'hapi-swagger': { 18 | id: 'config.get' 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./get'), 5 | require('./patch'), 6 | require('./replace'), 7 | require('./reset') 8 | ] 9 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/config/patch.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi 5 | } = require('../../utils/validation') 6 | 7 | module.exports = { 8 | method: 'PATCH', 9 | path: '/config', 10 | options: { 11 | handler: (request, reply) => { 12 | return request.server.app.ipfs.config.get() 13 | .then(config => { 14 | const patched = Object.assign({}, config, request.payload) 15 | 16 | return request.server.app.ipfs.config.replace(patched) 17 | }) 18 | .then(() => request.server.app.ipfs.config.get()) 19 | }, 20 | description: 'Replaces part of the current config', 21 | notes: [ 22 | 'The daemon will have to be restarted manually for the changes to take effect' 23 | ], 24 | tags: ['api'], 25 | validate: { 26 | payload: Joi 27 | .object() 28 | .description('A JSON object that contains the new config') 29 | .label('update-config-body') 30 | }, 31 | plugins: { 32 | 'hapi-swagger': { 33 | id: 'config.patch' 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/config/replace.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi 5 | } = require('../../utils/validation') 6 | 7 | module.exports = { 8 | method: 'PUT', 9 | path: '/config', 10 | options: { 11 | handler: (request, reply) => { 12 | return request.server.app.ipfs.config.replace(request.payload) 13 | .then(() => request.server.app.ipfs.config.get()) 14 | }, 15 | description: 'Replaces the current config', 16 | notes: [ 17 | 'The daemon will have to be restarted manually for the changes to take effect' 18 | ], 19 | tags: ['api'], 20 | validate: { 21 | payload: Joi 22 | .object() 23 | .description('A JSON object that contains the new config') 24 | .label('replace-config-body') 25 | }, 26 | plugins: { 27 | 'hapi-swagger': { 28 | id: 'config.replace' 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/config/reset.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi 5 | } = require('../../utils/validation') 6 | 7 | module.exports = { 8 | method: 'DELETE', 9 | path: '/config', 10 | options: { 11 | handler: (request, reply) => { 12 | return request.server.app.ipfs.config.replace(null) 13 | .then(() => request.server.app.ipfs.config.get()) 14 | }, 15 | description: 'Resets the current config to default values', 16 | notes: [ 17 | 'The daemon will have to be restarted manually for the changes to take effect' 18 | ], 19 | tags: ['api'], 20 | plugins: { 21 | 'hapi-swagger': { 22 | id: 'config.reset' 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dag/create.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi, 5 | cidVersion 6 | } = require('../../utils/validation') 7 | const mh = require('multihashes') 8 | 9 | module.exports = { 10 | method: 'POST', 11 | path: '/dag', 12 | options: { 13 | handler: (request, reply) => { 14 | 15 | }, 16 | description: 'Store an IPLD format node', 17 | notes: [ 18 | 'The dag API supports the creation and manipulation of dag-pb object, as well as other IPLD formats (i.e dag-cbor, ethereum-block, git, etc)' 19 | ], 20 | tags: ['api'], 21 | validate: { 22 | payload: Joi.object({ 23 | data: Joi 24 | .string(), 25 | links: Joi 26 | .array() 27 | .items(Joi.object({ 28 | name: Joi 29 | .string(), 30 | size: Joi 31 | .number() 32 | .integer() 33 | .min(0), 34 | cid: Joi 35 | .cid() 36 | .required() 37 | }).label('DAGLink')) 38 | }).label('DAGNode'), 39 | query: { 40 | format: Joi 41 | .string() 42 | .valid('dag-cbor', 'dag-pb') 43 | .default('dag-cbor'), 44 | hashAlg: Joi 45 | .string() 46 | .valid(Object.keys(mh.names)) 47 | .default('sha2-256'), 48 | cidVersion: cidVersion 49 | } 50 | }, 51 | plugins: { 52 | 'hapi-swagger': { 53 | id: 'dag.create' 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dag/get.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi, 10 | cidVersion, 11 | cidBase 12 | } = require('../../utils/validation') 13 | const transformHash = require('../../utils/transform-hash') 14 | 15 | module.exports = { 16 | method: 'GET', 17 | path: '/dag/{cid}', 18 | options: { 19 | handler: (request, reply) => { 20 | let promise 21 | 22 | if (request.headers.accept === EVERYTHING) { 23 | request.headers.accept = JSON 24 | } 25 | 26 | if (request.headers.accept === JSON) { 27 | promise = request.server.app.ipfs.dag.get(request.params.cid, request.query.path, { 28 | localResolve: request.query.localResolve 29 | }) 30 | .then(result => { 31 | const output = result.value.toJSON() 32 | 33 | output.cid = transformHash(output.multihash, request.query.cidVersion, request.query.cidBase) 34 | delete output.multihash 35 | 36 | if (output.data) { 37 | output.data = output.data.toString('base64') 38 | } 39 | 40 | if (output.links) { 41 | output.links = output.links.map(link => { 42 | link.cid = transformHash(link.multihash, request.query.cidVersion, request.query.cidBase) 43 | delete link.multihash 44 | 45 | return link 46 | }) 47 | } 48 | 49 | return output 50 | }) 51 | } else { 52 | promise = request.server.app.ipfs.dag.data(request.params.cid, { 53 | offset: request.query.offset, 54 | length: request.query.length 55 | }) 56 | } 57 | 58 | return promise 59 | }, 60 | description: 'Get a DAG node', 61 | notes: 'Resolves a DAG node with the passed CID', 62 | tags: ['api'], 63 | validate: { 64 | params: { 65 | cid: Joi 66 | .cid() 67 | .description('The CID that corresponds to the DAG node we wish to retrieve') 68 | }, 69 | query: { 70 | cidBase, 71 | cidVersion, 72 | path: Joi 73 | .string() 74 | .description('Path to resolve within this DAGNode'), 75 | offset: Joi 76 | .number() 77 | .integer() 78 | .min(0) 79 | .description('Byte offset to start streaming from'), 80 | length: Joi 81 | .number() 82 | .integer() 83 | .min(0) 84 | .description('Max number of bytes to stream'), 85 | localResolve: Joi 86 | .boolean() 87 | .default(false) 88 | .description('If set to true, it will avoid resolving through different objects') 89 | }, 90 | headers: { 91 | accept: Joi.string() 92 | .default(JSON) 93 | .valid([ 94 | JSON, 95 | OCTET_STREAM, 96 | EVERYTHING 97 | ]) 98 | }, 99 | options: { 100 | allowUnknown: true 101 | } 102 | }, 103 | plugins: { 104 | 'hapi-swagger': { 105 | id: 'dag.get' 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dag/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./remove'), 5 | require('./get'), 6 | require('./create'), 7 | require('./update') 8 | ] 9 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dag/remove.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi 5 | } = require('../../utils/validation') 6 | 7 | module.exports = { 8 | method: 'DELETE', 9 | path: '/dag/{cid}', 10 | options: { 11 | handler: (request, reply) => {}, 12 | description: 'Remove a DAG node from your local repo', 13 | notes: 'This will not remove a DAG node from IPFS if other nodes have it', 14 | tags: ['api'], 15 | validate: { 16 | params: { 17 | cid: Joi 18 | .string() 19 | .required() 20 | .description('The CID that corresponds to the DAG node we wish to remove') 21 | } 22 | }, 23 | plugins: { 24 | 'hapi-swagger': { 25 | id: 'dag.remove' 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dag/update.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi, 5 | cidVersion 6 | } = require('../../utils/validation') 7 | const mh = require('multihashes') 8 | 9 | module.exports = { 10 | method: 'PATCH', 11 | path: '/dag/{cid}', 12 | options: { 13 | handler: (request, reply) => { 14 | 15 | }, 16 | description: 'Update an IPLD format node', 17 | notes: [ 18 | 'This will result in a new DAG node being created' 19 | ], 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | cid: Joi 24 | .cid() 25 | .description('The CID that corresponds to the DAG node we wish to create') 26 | }, 27 | payload: Joi.object({ 28 | data: Joi 29 | .string(), 30 | links: Joi 31 | .array() 32 | .items(Joi.object({ 33 | name: Joi 34 | .string(), 35 | size: Joi 36 | .number() 37 | .integer() 38 | .min(0), 39 | cid: Joi 40 | .cid() 41 | .required() 42 | }).label('DAGLink')) 43 | }).label('DAGNode'), 44 | query: { 45 | format: Joi 46 | .string() 47 | .valid('dag-cbor', 'dag-pb') 48 | .default('dag-cbor'), 49 | hashAlg: Joi 50 | .string() 51 | .valid(Object.keys(mh.names)) 52 | .default('sha2-256'), 53 | cidVersion: cidVersion 54 | }, 55 | }, 56 | plugins: { 57 | 'hapi-swagger': { 58 | id: 'dag.update' 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/find-peer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/dht/peer/{peerId}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.findpeer(request.params.peerId) 18 | }, 19 | description: 'Retrieve the Peer Info of a reachable node in the network', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | peerId: Joi 24 | .peerId() 25 | .description('The Peer ID that we wish to find info about') 26 | }, 27 | headers: { 28 | accept: Joi.string() 29 | .default(JSON) 30 | .valid([ 31 | JSON, 32 | EVERYTHING 33 | ]) 34 | }, 35 | options: { 36 | allowUnknown: true 37 | } 38 | }, 39 | plugins: { 40 | 'hapi-swagger': { 41 | id: 'dht.findPeer' 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/find-providers.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/dht/providers/{cid}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.findprovs(request.params.cid, { 18 | timeout: request.query.timeout 19 | }) 20 | }, 21 | description: 'Retrieve the providers for content that is addressed by an hash', 22 | tags: ['api'], 23 | validate: { 24 | params: { 25 | cid: Joi 26 | .cid() 27 | .description('The content id that we wish to find providers for') 28 | }, 29 | query: { 30 | timeout: Joi 31 | .number() 32 | .integer() 33 | .min(0) 34 | }, 35 | headers: { 36 | accept: Joi.string() 37 | .default(JSON) 38 | .valid([ 39 | JSON, 40 | EVERYTHING 41 | ]) 42 | }, 43 | options: { 44 | allowUnknown: true 45 | } 46 | }, 47 | plugins: { 48 | 'hapi-swagger': { 49 | id: 'dht.findProviders', 50 | responses: { 51 | 404: { 52 | description: 'No provider could be found for the passed CID' 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/get.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/dht/{key}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.get(request.params.cid) 18 | }, 19 | description: 'Retrieve a value from the DHT', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | key: Joi 24 | .string() 25 | .description('The key to retrieve the associated value for') 26 | }, 27 | headers: { 28 | accept: Joi.string() 29 | .default(JSON) 30 | .valid([ 31 | JSON, 32 | EVERYTHING 33 | ]) 34 | }, 35 | options: { 36 | allowUnknown: true 37 | } 38 | }, 39 | plugins: { 40 | 'hapi-swagger': { 41 | id: 'dht.get' 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./find-peer'), 5 | require('./find-providers'), 6 | require('./get'), 7 | require('./provide'), 8 | require('./put'), 9 | require('./query') 10 | ] 11 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/provide.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/dht/provide', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.provide(request.payload, { 18 | recursive: request.query.recursive 19 | }) 20 | .then(() => reply.response().code(204)) 21 | }, 22 | description: 'Announce to the network that you are providing given values', 23 | tags: ['api'], 24 | validate: { 25 | payload: Joi 26 | .array() 27 | .description('The content IDs you are announcing') 28 | .items(Joi 29 | .cid() 30 | .label('cid') 31 | ) 32 | .label('cid-list'), 33 | query: { 34 | recursive: Joi 35 | .boolean() 36 | .default(false) 37 | .description('Recursively provide the entire graph') 38 | }, 39 | headers: { 40 | accept: Joi.string() 41 | .default(JSON) 42 | .valid([ 43 | JSON, 44 | EVERYTHING 45 | ]) 46 | }, 47 | options: { 48 | allowUnknown: true 49 | } 50 | }, 51 | plugins: { 52 | 'hapi-swagger': { 53 | id: 'dht.provide', 54 | consumes: ['application/json'] 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/put.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/dht/{key}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.put(request.params.key, request.payload) 18 | }, 19 | description: 'Store a value on the DHT', 20 | tags: ['api'], 21 | validate: { 22 | payload: Joi.object({ 23 | value: Joi 24 | .string() 25 | .required() 26 | }).label('dht-value'), 27 | params: { 28 | key: Joi 29 | .cid() 30 | .required() 31 | .description('The content id you are storing') 32 | }, 33 | headers: { 34 | accept: Joi.string() 35 | .default(JSON) 36 | .valid([ 37 | JSON, 38 | EVERYTHING 39 | ]) 40 | }, 41 | options: { 42 | allowUnknown: true 43 | } 44 | }, 45 | plugins: { 46 | 'hapi-swagger': { 47 | id: 'dht.put' 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/dht/query.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/dht/query/{peerId}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dht.query(request.params.peerId) 18 | }, 19 | description: 'Queries the network for the \'closest peers\' to a given key', 20 | notes: [ 21 | '\'closest\' is defined by the rules of the underlying Peer Routing mechanism' 22 | ], 23 | tags: ['api'], 24 | validate: { 25 | params: { 26 | peerId: Joi 27 | .peerId() 28 | .required() 29 | .description('An IPFS/libp2p peer ID') 30 | }, 31 | headers: { 32 | accept: Joi.string() 33 | .default(JSON) 34 | .valid([ 35 | JSON, 36 | EVERYTHING 37 | ]) 38 | }, 39 | options: { 40 | allowUnknown: true 41 | } 42 | }, 43 | plugins: { 44 | 'hapi-swagger': { 45 | id: 'dht.query' 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/create.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi, 5 | cidVersion, 6 | cidBase 7 | } = require('../../utils/validation') 8 | const mh = require('multihashes') 9 | 10 | module.exports = { 11 | method: 'POST', 12 | path: '/files/{path}', 13 | options: { 14 | handler: (request, reply) => { 15 | if (request.payload && request.payload.file) { 16 | return request.server.app.ipfs.files.write(request.params.path, request.payload.file, { 17 | create: true, 18 | offset: request.query.offset, 19 | length: request.query.length, 20 | truncate: false, 21 | parents: request.query.parents, 22 | rawLeaves: request.query.rawLeaves, 23 | flush: request.query.flush, 24 | cidVersion: request.query.cidVersion, 25 | hashAlg: request.query.hashAlg 26 | }) 27 | .then(() => { 28 | return reply.response().code(204) 29 | }) 30 | .catch((error) => { 31 | if (error.message === 'file already exists') { 32 | return reply.response().code(409) 33 | } 34 | 35 | if (error.message === 'file does not exist') { 36 | return reply.response().code(409) 37 | } 38 | 39 | throw error 40 | }) 41 | } else { 42 | return request.server.app.ipfs.files.mkdir(request.params.path, { 43 | parents: request.query.parents, 44 | cidVersion: request.query.cidVersion, 45 | hashAlg: request.query.hashAlg 46 | }) 47 | .then(() => { 48 | return reply.response().code(204) 49 | }) 50 | .catch((error) => { 51 | if (error.message === 'file already exists') { 52 | return reply.response().code(409) 53 | } 54 | 55 | throw error 56 | }) 57 | } 58 | }, 59 | description: 'Create an MFS path', 60 | notes: 'Create a new file or directory at the passed MFS path', 61 | tags: ['api'], 62 | payload: { 63 | output: 'stream', 64 | parse: true, 65 | allow: ['multipart/form-data', 'application/octet-stream'] 66 | }, 67 | validate: { 68 | payload: { 69 | file: Joi.any() 70 | .meta({ 71 | swaggerType: 'file' 72 | }) 73 | .description('The file you wish to write') 74 | }, 75 | params: { 76 | path: Joi 77 | .string() 78 | .required() 79 | .description('The MFS path you wish to create') 80 | }, 81 | query: { 82 | offset: Joi 83 | .number() 84 | .integer() 85 | .min(0) 86 | .default(0) 87 | .description('Byte offset to begin writing at'), 88 | parents: Joi 89 | .boolean() 90 | .default(false) 91 | .description('Make parent directories as needed'), 92 | length: Joi 93 | .number() 94 | .integer() 95 | .min(0) 96 | .description('Maximum number of bytes to write'), 97 | rawLeaves: Joi 98 | .boolean() 99 | .default(false) 100 | .description('Use raw blocks for newly created leaf nodes'), 101 | hashAlg: Joi 102 | .string() 103 | .valid(Object.keys(mh.names)) 104 | .default('sha2-256'), 105 | cidVersion: Joi 106 | .number() 107 | .integer() 108 | .positive() 109 | .valid([0, 1]) 110 | .default(1) 111 | .description('Which CID version to use'), 112 | flush: Joi 113 | .boolean() 114 | .default(true) 115 | .description('Flush the changes to disk immediately') 116 | } 117 | }, 118 | plugins: { 119 | 'hapi-swagger': { 120 | id: 'files.create', 121 | payloadType: 'form', 122 | produces: ['application/json'], 123 | consumes: ['application/octet-stream', 'multipart/form-data'], 124 | responses: { 125 | 204: { 126 | description: 'The file or directory was created' 127 | }, 128 | 409: { 129 | description: 'The file or directory already exists' 130 | } 131 | } 132 | } 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/get.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | const Boom = require('boom') 5 | const CID = require('cids') 6 | const { 7 | JSON, 8 | OCTET_STREAM 9 | } = require('../../utils/mime-types') 10 | const cidVersion = require('../../utils/validation/cid-version') 11 | const cidBase = require('../../utils/validation/cid-base') 12 | const transformHash = require('../../utils/transform-hash') 13 | const TYPES = [ 14 | 'file', 15 | 'directory' 16 | ] 17 | 18 | module.exports = { 19 | method: 'GET', 20 | path: '/files/{path}', 21 | options: { 22 | handler: (request, reply) => { 23 | let promise 24 | 25 | if (request.headers.accept === JSON) { 26 | promise = request.server.app.ipfs.files.stat(request.params.path) 27 | .then(result => { 28 | result.cid = transformHash(result.hash, request.query.cidVersion, request.query.cidBase) 29 | delete result.hash 30 | 31 | if (result.type === 'directory') { 32 | return request.server.app.ipfs.files.ls(request.params.path, { 33 | long: true 34 | }) 35 | .then(contents => { 36 | result.contents = contents.map(entry => { 37 | entry.type = TYPES[entry.type] 38 | 39 | if (entry.type === 'directory') { 40 | delete entry.size 41 | } 42 | 43 | entry.cid = transformHash(entry.hash, request.query.cidVersion, request.query.cidBase) 44 | delete entry.hash 45 | 46 | return entry 47 | }) 48 | 49 | return result 50 | }) 51 | } 52 | 53 | return result 54 | }) 55 | } else { 56 | promise = request.server.app.ipfs.files.read(request.params.path, { 57 | offset: request.query.offset, 58 | length: request.query.length 59 | }) 60 | } 61 | 62 | return promise 63 | .catch(error => { 64 | if (error.message.includes('does not exist')) { 65 | throw Boom.notFound() 66 | } else if (error.message.includes('paths must start with a leading /')) { 67 | throw Boom.badRequest(error.message) 68 | } else if (error.message.includes('was not a file')) { 69 | throw Boom.badRequest(error.message) 70 | } 71 | 72 | throw Boom.badImplementation(error) 73 | }) 74 | }, 75 | description: 'Get a file or directory from your MFS', 76 | notes: [ 77 | 'Returns a file or directory from your MFS', 78 | 'Specify `accept: application/json` for file/directory metadata or `accept: application/octet-stream` to download file data.', 79 | 'If the path resolves to a file and `accept: application/octet-stream` has been specified, you may pass the `offset` and `length` parameters.' 80 | ], 81 | tags: ['api'], 82 | validate: { 83 | params: { 84 | path: Joi 85 | .string() 86 | .required() 87 | .regex(/^\//) 88 | .description('The MFS path you wish to retrieve') 89 | .default('/') 90 | }, 91 | query: { 92 | offset: Joi 93 | .description('Return file data starting at this offset') 94 | .when('$headers.accept', { 95 | is: OCTET_STREAM, 96 | then: Joi 97 | .number() 98 | .integer() 99 | .positive() 100 | .unit('bytes'), 101 | otherwise: Joi.forbidden() 102 | }), 103 | length: Joi 104 | .description('Return only this many bytes of file data') 105 | .when('$headers.accept', { 106 | is: OCTET_STREAM, 107 | then: Joi 108 | .number() 109 | .integer() 110 | .positive() 111 | .unit('bytes'), 112 | otherwise: Joi.forbidden() 113 | }), 114 | cidBase, 115 | cidVersion 116 | }, 117 | headers: { 118 | accept: Joi.string() 119 | .default(JSON) 120 | .valid([ 121 | JSON, 122 | OCTET_STREAM 123 | ]) 124 | }, 125 | options: { 126 | allowUnknown: true 127 | } 128 | }, 129 | response: { 130 | status: { 131 | 200: Joi.object({ 132 | cid: Joi 133 | .string() 134 | .required(), 135 | type: Joi 136 | .string() 137 | .required() 138 | .valid(['file', 'directory']), 139 | cumulativeSize: Joi 140 | .number() 141 | .integer() 142 | .positive() 143 | .required(), 144 | blocks: Joi 145 | .number() 146 | .integer() 147 | .required(), 148 | size: Joi 149 | .number() 150 | .integer(), 151 | withLocality: Joi 152 | .boolean(), 153 | local: Joi 154 | .boolean(), 155 | sizeLocal: Joi 156 | .number() 157 | .integer(), 158 | contents: Joi 159 | .array() 160 | .items(Joi.object({ 161 | name: Joi 162 | .string() 163 | .required(), 164 | type: Joi 165 | .string() 166 | .required() 167 | .valid(['file', 'directory']), 168 | cid: Joi.string().required(), 169 | size: Joi.number().integer() 170 | }).label('unixfs-entry-summary') 171 | ) 172 | }).label('unixfs-entry') 173 | } 174 | }, 175 | plugins: { 176 | 'hapi-swagger': { 177 | id: 'files.get' 178 | } 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./create'), 5 | require('./get'), 6 | require('./remove'), 7 | require('./replace'), 8 | require('./update') 9 | ] 10 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/remove.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | 5 | module.exports = { 6 | method: 'DELETE', 7 | path: '/files/{path}', 8 | options: { 9 | handler: (request, reply) => { 10 | return request.server.app.ipfs.files.rm(request.params.path, { 11 | recursive: request.query.recursive 12 | }) 13 | .then(() => { 14 | return reply.response().code(204) 15 | }) 16 | .catch(error => { 17 | if (error.message === 'Cannot delete root') { 18 | return reply.response().code(409) 19 | } 20 | 21 | if (error.message === 'file does not exist') { 22 | return reply.response().code(404) 23 | } 24 | 25 | if (error.message.includes('is a directory')) { 26 | return reply.response().code(409) 27 | } 28 | 29 | throw error 30 | }) 31 | }, 32 | description: 'Remove an MFS path', 33 | notes: 'Removes a directory or file from your MFS', 34 | tags: ['api'], 35 | validate: { 36 | params: { 37 | path: Joi 38 | .string() 39 | .required() 40 | .description('The MFS path you wish to remove') 41 | }, 42 | query: { 43 | recursive: Joi 44 | .boolean() 45 | .default(false) 46 | .description('Remove directories recursively') 47 | } 48 | }, 49 | plugins: { 50 | 'hapi-swagger': { 51 | id: 'files.remove', 52 | responses: { 53 | 204: { 54 | description: 'The file or directory was deleted' 55 | }, 56 | 404: { 57 | description: 'The file or directory did not exist' 58 | }, 59 | 409: { 60 | description: 'The file or directory could not be deleted' 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/replace.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi, 5 | cidVersion, 6 | cidBase 7 | } = require('../../utils/validation') 8 | const mh = require('multihashes') 9 | 10 | module.exports = { 11 | method: 'PUT', 12 | path: '/files/{path}', 13 | options: { 14 | handler: (request, reply) => { 15 | if (request.payload && request.payload.file) { 16 | return request.server.app.ipfs.files.write(request.params.path, request.payload.file, { 17 | create: false, 18 | truncate: true, 19 | parents: request.query.parents, 20 | rawLeaves: request.query.rawLeaves, 21 | flush: request.query.flush, 22 | cidVersion: request.query.cidVersion, 23 | hashAlg: request.query.hashAlg 24 | }) 25 | .then(() => { 26 | return reply.response().code(204) 27 | }) 28 | .catch((error) => { 29 | if (error.message === 'file already exists') { 30 | return reply.response().code(409) 31 | } 32 | 33 | if (error.message === 'file does not exist') { 34 | return reply.response().code(409) 35 | } 36 | 37 | throw error 38 | }) 39 | } else { 40 | return request.server.app.ipfs.files.mkdir(request.params.path, { 41 | parents: request.query.parents, 42 | cidVersion: request.query.cidVersion, 43 | hashAlg: request.query.hashAlg 44 | }) 45 | .then(() => { 46 | return reply.response().code(204) 47 | }) 48 | .catch((error) => { 49 | if (error.message === 'file already exists') { 50 | return reply.response().code(409) 51 | } 52 | 53 | throw error 54 | }) 55 | } 56 | }, 57 | description: 'Update an MFS path', 58 | notes: 'Updates a file or directory at the passed MFS path', 59 | tags: ['api'], 60 | payload: { 61 | output: 'stream', 62 | parse: true, 63 | allow: ['multipart/form-data', 'application/octet-stream'] 64 | }, 65 | validate: { 66 | payload: { 67 | file: Joi.any() 68 | .meta({ 69 | swaggerType: 'file' 70 | }) 71 | .description('The file you wish to write') 72 | }, 73 | params: { 74 | path: Joi 75 | .string() 76 | .required() 77 | .description('The MFS path you wish to update') 78 | }, 79 | query: { 80 | parents: Joi 81 | .boolean() 82 | .default(false) 83 | .description('Make parent directories as needed'), 84 | rawLeaves: Joi 85 | .boolean() 86 | .default(false) 87 | .description('Use raw blocks for newly created leaf nodes'), 88 | hashAlg: Joi 89 | .string() 90 | .valid(Object.keys(mh.names)) 91 | .default('sha2-256'), 92 | cidVersion: Joi 93 | .number() 94 | .integer() 95 | .positive() 96 | .valid([0, 1]) 97 | .default(1) 98 | .description('Which CID version to use'), 99 | flush: Joi 100 | .boolean() 101 | .default(true) 102 | .description('Flush the changes to disk immediately') 103 | } 104 | }, 105 | plugins: { 106 | 'hapi-swagger': { 107 | id: 'files.replace', 108 | payloadType: 'form', 109 | produces: ['application/json'], 110 | consumes: ['application/octet-stream', 'multipart/form-data'], 111 | responses: { 112 | 204: { 113 | description: 'The file or directory was created' 114 | }, 115 | 409: { 116 | description: 'The file or directory already exists' 117 | } 118 | } 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/files/update.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | Joi, 5 | cidVersion, 6 | cidBase 7 | } = require('../../utils/validation') 8 | const mh = require('multihashes') 9 | 10 | module.exports = { 11 | method: 'PATCH', 12 | path: '/files/{path}', 13 | options: { 14 | handler: (request, reply) => { 15 | if (request.payload && request.payload.file) { 16 | return request.server.app.ipfs.files.write(request.params.path, request.payload.file, { 17 | create: false, 18 | offset: request.query.offset, 19 | length: request.query.length, 20 | truncate: request.query.truncate, 21 | parents: request.query.parents, 22 | rawLeaves: request.query.rawLeaves, 23 | truncate: request.query.truncate, 24 | flush: request.query.flush, 25 | cidVersion: request.query.cidVersion, 26 | hashAlg: request.query.hashAlg 27 | }) 28 | .then(() => { 29 | return reply.response().code(204) 30 | }) 31 | .catch((error) => { 32 | if (error.message === 'file already exists') { 33 | return reply.response().code(409) 34 | } 35 | 36 | if (error.message === 'file does not exist') { 37 | return reply.response().code(409) 38 | } 39 | 40 | throw error 41 | }) 42 | } else { 43 | return request.server.app.ipfs.files.mkdir(request.params.path, { 44 | parents: request.query.parents, 45 | cidVersion: request.query.cidVersion, 46 | hashAlg: request.query.hashAlg 47 | }) 48 | .then(() => { 49 | return reply.response().code(204) 50 | }) 51 | .catch((error) => { 52 | if (error.message === 'file already exists') { 53 | return reply.response().code(409) 54 | } 55 | 56 | throw error 57 | }) 58 | } 59 | }, 60 | description: 'Update an MFS path', 61 | notes: 'Updates a file or directory at the passed MFS path', 62 | tags: ['api'], 63 | payload: { 64 | output: 'stream', 65 | parse: true, 66 | allow: ['multipart/form-data', 'application/octet-stream'] 67 | }, 68 | validate: { 69 | payload: { 70 | file: Joi.any() 71 | .meta({ 72 | swaggerType: 'file' 73 | }) 74 | .description('The file you wish to write') 75 | }, 76 | params: { 77 | path: Joi 78 | .string() 79 | .required() 80 | .description('The MFS path you wish to update') 81 | }, 82 | query: { 83 | offset: Joi 84 | .number() 85 | .integer() 86 | .min(0) 87 | .default(0) 88 | .description('Byte offset to begin writing at'), 89 | parents: Joi 90 | .boolean() 91 | .default(false) 92 | .description('Make parent directories as needed'), 93 | truncate: Joi 94 | .boolean() 95 | .default(true) 96 | .description('Truncate the file to size zero before writing'), 97 | length: Joi 98 | .number() 99 | .integer() 100 | .min(0) 101 | .description('Maximum number of bytes to write'), 102 | rawLeaves: Joi 103 | .boolean() 104 | .default(false) 105 | .description('Use raw blocks for newly created leaf nodes'), 106 | hashAlg: Joi 107 | .string() 108 | .valid(Object.keys(mh.names)) 109 | .default('sha2-256'), 110 | cidVersion: Joi 111 | .number() 112 | .integer() 113 | .positive() 114 | .valid([0, 1]) 115 | .default(1) 116 | .description('Which CID version to use'), 117 | flush: Joi 118 | .boolean() 119 | .default(true) 120 | .description('Flush the changes to disk immediately') 121 | } 122 | }, 123 | plugins: { 124 | 'hapi-swagger': { 125 | id: 'files.update', 126 | payloadType: 'form', 127 | produces: ['application/json'], 128 | consumes: ['application/octet-stream', 'multipart/form-data'], 129 | responses: { 130 | 204: { 131 | description: 'The file or directory was created' 132 | }, 133 | 409: { 134 | description: 'The file or directory already exists' 135 | } 136 | } 137 | } 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const routes = [] 4 | .concat(require('./bitswap')) 5 | .concat(require('./config')) 6 | .concat(require('./dag')) 7 | .concat(require('./dht')) 8 | .concat(require('./files')) 9 | .concat(require('./key')) 10 | .concat(require('./miscellaneous')) 11 | .concat(require('./name')) 12 | .concat(require('./pin')) 13 | .concat(require('./pubsub')) 14 | .concat(require('./repo')) 15 | .concat(require('./swarm')) 16 | 17 | module.exports = routes 18 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/key/generate.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING, 7 | PEM 8 | } = require('../../utils/mime-types') 9 | const { 10 | Joi, 11 | stream 12 | } = require('../../utils/validation') 13 | 14 | module.exports = { 15 | method: 'POST', 16 | path: '/key', 17 | options: { 18 | handler: (request, reply) => { 19 | return null 20 | }, 21 | description: 'Create a new keypair', 22 | tags: ['api'], 23 | validate: { 24 | payload: Joi.object({ 25 | name: Joi.string().required(), 26 | pem: Joi 27 | .string() 28 | .description('base64 encoded PKCS #8 PEM file to import keypairs from'), 29 | password: Joi 30 | .string() 31 | .description('Password to PKCS #8 PEM file'), 32 | }).label('generate-keypair-payload'), 33 | headers: { 34 | accept: Joi.string() 35 | .default(JSON) 36 | .valid([ 37 | JSON, 38 | EVERYTHING 39 | ]) 40 | }, 41 | options: { 42 | allowUnknown: true 43 | } 44 | }, 45 | plugins: { 46 | 'hapi-swagger': { 47 | id: 'key.generate' 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/key/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./generate'), 5 | require('./list'), 6 | require('./remove'), 7 | require('./rename') 8 | ] 9 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/key/list.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/key', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.key.list() 18 | }, 19 | description: 'List all local keypairs', 20 | tags: ['api'], 21 | validate: { 22 | headers: { 23 | accept: Joi.string() 24 | .default(JSON) 25 | .valid([ 26 | JSON, 27 | EVERYTHING 28 | ]) 29 | }, 30 | options: { 31 | allowUnknown: true 32 | } 33 | }, 34 | plugins: { 35 | 'hapi-swagger': { 36 | id: 'key.list' 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/key/remove.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'DELETE', 14 | path: '/key/{name}', 15 | options: { 16 | handler: (request, reply) => { 17 | return null 18 | }, 19 | description: 'Remove a keypair', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | name: Joi.string().required() 24 | }, 25 | headers: { 26 | accept: Joi.string() 27 | .default(JSON) 28 | .valid([ 29 | JSON, 30 | EVERYTHING 31 | ]) 32 | }, 33 | options: { 34 | allowUnknown: true 35 | } 36 | }, 37 | plugins: { 38 | 'hapi-swagger': { 39 | id: 'key.remove' 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/key/rename.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'PATCH', 14 | path: '/key/{name}', 15 | options: { 16 | handler: (request, reply) => { 17 | return null 18 | }, 19 | description: 'Rename a keypair', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | name: Joi.string().required() 24 | }, 25 | payload: Joi.object({ 26 | name: Joi.string().required() 27 | }).label('rename-keypair-payload'), 28 | headers: { 29 | accept: Joi.string() 30 | .default(JSON) 31 | .valid([ 32 | JSON, 33 | EVERYTHING 34 | ]) 35 | }, 36 | options: { 37 | allowUnknown: true 38 | } 39 | }, 40 | plugins: { 41 | 'hapi-swagger': { 42 | id: 'key.rename' 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/miscellaneous/dns.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/dns/{path}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.dns(request.params.path) 18 | .catch(error => { 19 | if ( 20 | error.code === 'ENOTFOUND' || 21 | error.code === 'ENODATA' || 22 | error.message.includes('domain does not have a txt dnslink entry') 23 | ) { 24 | return reply.response().code(404) 25 | } 26 | 27 | throw error 28 | }) 29 | }, 30 | description: 'Resolve DNS links', 31 | tags: ['api'], 32 | validate: { 33 | params: { 34 | path: Joi 35 | .string() 36 | .required() 37 | }, 38 | headers: { 39 | accept: Joi 40 | .string() 41 | .default(JSON) 42 | .valid([ 43 | JSON, 44 | EVERYTHING 45 | ]) 46 | }, 47 | options: { 48 | allowUnknown: true 49 | } 50 | }, 51 | response: { 52 | status: { 53 | 200: Joi.string() 54 | } 55 | }, 56 | plugins: { 57 | 'hapi-swagger': { 58 | id: 'miscellaneous.dns', 59 | responses: { 60 | 404: { 61 | description: 'The DNS name could not be resolved' 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/miscellaneous/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./dns') 5 | ] 6 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/name/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./publish'), 5 | require('./resolve') 6 | ] 7 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/name/publish.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/name', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.name.publish(request.payload.value, { 18 | resolve: request.payload.recursive, 19 | lifetime: request.payload.lifetime, 20 | ttl: request.payload.ttl, 21 | key: request.payload.key, 22 | }) 23 | }, 24 | description: 'Publish an IPNS name with a given value', 25 | tags: ['api'], 26 | validate: { 27 | payload: Joi.object({ 28 | value: Joi 29 | .string() 30 | .required(), 31 | resolve: Joi 32 | .boolean() 33 | .default(false) 34 | .description('Resolve given path before publishing'), 35 | lifetime: Joi 36 | .string() 37 | .default('24h') 38 | .description('Time duration of the record'), 39 | ttl: Joi 40 | .string() 41 | .default('24h') 42 | .description('Time duration this record should be cached'), 43 | key: Joi 44 | .string() 45 | .default('self') 46 | .description('Name of the key to be used or Peer ID') 47 | }).label('ipns-options'), 48 | headers: { 49 | accept: Joi 50 | .string() 51 | .default(JSON) 52 | .valid([ 53 | JSON, 54 | EVERYTHING 55 | ]) 56 | }, 57 | options: { 58 | allowUnknown: true 59 | } 60 | }, 61 | response: { 62 | status: { 63 | 200: Joi.object({ 64 | name: Joi.string(), 65 | value: Joi.string() 66 | }).label('ipns-record') 67 | } 68 | }, 69 | plugins: { 70 | 'hapi-swagger': { 71 | id: 'name.publish' 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/name/resolve.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/name/{name}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.name.resolve(request.params.name, { 18 | recursive: request.query.recursive, 19 | nocache: request.query.nocache 20 | }) 21 | }, 22 | description: 'Resolve an IPNS name', 23 | tags: ['api'], 24 | validate: { 25 | params: { 26 | name: Joi 27 | .string() 28 | .required() 29 | }, 30 | query: { 31 | recursive: Joi 32 | .boolean() 33 | .default(false), 34 | nocache: Joi 35 | .boolean() 36 | .default(false) 37 | }, 38 | headers: { 39 | accept: Joi 40 | .string() 41 | .default(JSON) 42 | .valid([ 43 | JSON, 44 | EVERYTHING 45 | ]) 46 | }, 47 | options: { 48 | allowUnknown: true 49 | } 50 | }, 51 | response: { 52 | status: { 53 | 200: Joi.string() 54 | } 55 | }, 56 | plugins: { 57 | 'hapi-swagger': { 58 | id: 'name.resolve', 59 | responses: { 60 | 404: { 61 | description: 'The IPNS name could not be resolved' 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pin/create.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/pins', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.pin.add(request.payload.hash, { 18 | recursive: request.query.recursive 19 | }) 20 | .then(() => reply.response().code(204)) 21 | }, 22 | description: 'Remove a hash from the pinset', 23 | tags: ['api'], 24 | validate: { 25 | payload: Joi.object({ 26 | hash: Joi 27 | .cid() 28 | .required() 29 | }).label('create-pin-payload'), 30 | query: { 31 | recursive: Joi 32 | .boolean() 33 | .default(true) 34 | }, 35 | headers: { 36 | accept: Joi 37 | .string() 38 | .default(JSON) 39 | .valid([ 40 | JSON, 41 | EVERYTHING 42 | ]) 43 | }, 44 | options: { 45 | allowUnknown: true 46 | } 47 | }, 48 | plugins: { 49 | 'hapi-swagger': { 50 | id: 'pin.add', 51 | responses: { 52 | 404: { 53 | description: 'The pin could not be found' 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pin/get.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/pins/{cid}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.pin.ls(request.params.hash) 18 | }, 19 | description: 'List the objects pinned under a specific cid', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | cid: Joi 24 | .cid() 25 | .required() 26 | }, 27 | headers: { 28 | accept: Joi 29 | .string() 30 | .default(JSON) 31 | .valid([ 32 | JSON, 33 | EVERYTHING 34 | ]) 35 | }, 36 | options: { 37 | allowUnknown: true 38 | } 39 | }, 40 | response: { 41 | status: { 42 | 200: Joi.object({ 43 | hash: Joi 44 | .cid() 45 | .required(), 46 | type: Joi 47 | .string() 48 | .required() 49 | }).label('pin') 50 | } 51 | }, 52 | plugins: { 53 | 'hapi-swagger': { 54 | id: 'pin.get', 55 | responses: { 56 | 404: { 57 | description: 'The pin could not be found' 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pin/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./create'), 5 | require('./list'), 6 | require('./remove') 7 | ] 8 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pin/list.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi, 10 | cidBase, 11 | cidVersion 12 | } = require('../../utils/validation') 13 | const transformHash = require('../../utils/transform-hash') 14 | 15 | module.exports = { 16 | method: 'GET', 17 | path: '/pins', 18 | options: { 19 | handler: (request, reply) => { 20 | return request.server.app.ipfs.pin.ls(request.query.cid, { 21 | type: request.query.type 22 | }) 23 | .then(pinset => { 24 | return pinset.map(pin => { 25 | return { 26 | cid: transformHash(pin.hash, request.query.cidVersion, request.query.cidBase), 27 | type: pin.type 28 | } 29 | }) 30 | }) 31 | }, 32 | description: 'List all the objects pinned to local storage', 33 | tags: ['api'], 34 | validate: { 35 | query: { 36 | type: Joi 37 | .string() 38 | .default('all') 39 | .valid([ 40 | 'recursive', 41 | 'direct', 42 | 'indirect' 43 | ]), 44 | cid: Joi 45 | .cid(), 46 | cidBase, 47 | cidVersion 48 | }, 49 | headers: { 50 | accept: Joi 51 | .string() 52 | .default(JSON) 53 | .valid([ 54 | JSON, 55 | EVERYTHING 56 | ]) 57 | }, 58 | options: { 59 | allowUnknown: true 60 | } 61 | }, 62 | response: { 63 | status: { 64 | 200: Joi 65 | .array() 66 | .items(Joi.object({ 67 | cid: Joi 68 | .cid() 69 | .required(), 70 | type: Joi 71 | .string() 72 | .default('all') 73 | .required() 74 | .valid([ 75 | 'recursive', 76 | 'direct', 77 | 'indirect' 78 | ]) 79 | }) 80 | .label('pin') 81 | ).label('pins') 82 | } 83 | }, 84 | plugins: { 85 | 'hapi-swagger': { 86 | id: 'pin.list', 87 | responses: { 88 | 404: { 89 | description: 'The DNS name could not be resolved' 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pin/remove.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'DELETE', 14 | path: '/pins/{hash}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.pin.rm(request.params.hash, { 18 | recursive: request.query.recursive 19 | }) 20 | .then(() => reply.response().code(204)) 21 | }, 22 | description: 'Remove a hash from the pinset', 23 | tags: ['api'], 24 | validate: { 25 | params: { 26 | hash: Joi 27 | .cid() 28 | .required() 29 | }, 30 | query: { 31 | recursive: Joi 32 | .boolean() 33 | .default(true) 34 | }, 35 | headers: { 36 | accept: Joi 37 | .string() 38 | .default(JSON) 39 | .valid([ 40 | JSON, 41 | EVERYTHING 42 | ]) 43 | }, 44 | options: { 45 | allowUnknown: true 46 | } 47 | }, 48 | plugins: { 49 | 'hapi-swagger': { 50 | id: 'pin.remove', 51 | responses: { 52 | 204: { 53 | description: 'The pin was removed' 54 | }, 55 | 404: { 56 | description: 'The pin could not be found' 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./subscribe'), 5 | //require('./unsubscribe'), 6 | //require('./publish'), 7 | require('./list'), 8 | //require('./peers') 9 | ] 10 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/list.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/pubsub/topics', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.pubsub.ls() 18 | }, 19 | description: 'Returns the list of topics the peer is subscribed to', 20 | tags: ['api'], 21 | validate: { 22 | headers: { 23 | accept: Joi 24 | .string() 25 | .default(JSON) 26 | .valid([ 27 | JSON, 28 | EVERYTHING 29 | ]) 30 | }, 31 | options: { 32 | allowUnknown: true 33 | } 34 | }, 35 | /*response: { 36 | status: { 37 | 200: Joi 38 | .array() 39 | .items(Joi.object({ 40 | type: Joi 41 | .string() 42 | .default('all') 43 | .required() 44 | .valid([ 45 | 'recursive', 46 | 'direct', 47 | 'indirect' 48 | ]), 49 | hash: Joi 50 | .cid() 51 | .required() 52 | }).label('pin')) 53 | } 54 | },*/ 55 | plugins: { 56 | 'hapi-swagger': { 57 | id: 'pubsub.list' 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/peers.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-http/1c6f93780f749e05b0894f1a7d98bdb2bcc4d20d/packages/js-rest-server/routes/pubsub/peers.js -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/publish.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-http/1c6f93780f749e05b0894f1a7d98bdb2bcc4d20d/packages/js-rest-server/routes/pubsub/publish.js -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/subscribe.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/pubsub/topics', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.pubsub.subscribe(request.payload.topic, (message) => { 18 | 19 | }, { 20 | discover: request.payload.discover 21 | }, (error) => { 22 | if (error) { 23 | reply.reponse(error) 24 | } 25 | }) 26 | }, 27 | description: 'Returns the list of topics the peer is subscribed to', 28 | tags: ['api'], 29 | validate: { 30 | payload: Joi.object({ 31 | topic: Joi 32 | .string() 33 | .required(), 34 | discover: Joi 35 | .boolean() 36 | .default(false) 37 | }).label('subscribe-to-pubsub-topic-payload'), 38 | headers: { 39 | accept: Joi 40 | .string() 41 | .default(JSON) 42 | .valid([ 43 | JSON, 44 | EVERYTHING 45 | ]) 46 | }, 47 | options: { 48 | allowUnknown: true 49 | } 50 | }, 51 | plugins: { 52 | 'hapi-swagger': { 53 | id: 'pubsub.subscribe' 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/pubsub/unsubscribe.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-http/1c6f93780f749e05b0894f1a7d98bdb2bcc4d20d/packages/js-rest-server/routes/pubsub/unsubscribe.js -------------------------------------------------------------------------------- /packages/js-rest-server/routes/repo/gc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/repo/gc', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.repo.gc() 18 | }, 19 | description: 'Perform a garbage collection sweep on the repo', 20 | tags: ['api'], 21 | validate: { 22 | headers: { 23 | accept: Joi 24 | .string() 25 | .default(JSON) 26 | .valid([ 27 | JSON, 28 | EVERYTHING 29 | ]) 30 | }, 31 | options: { 32 | allowUnknown: true 33 | } 34 | }, 35 | /*response: { 36 | status: { 37 | 200: Joi 38 | .array() 39 | .items(Joi.object({ 40 | type: Joi 41 | .string() 42 | .default('all') 43 | .required() 44 | .valid([ 45 | 'recursive', 46 | 'direct', 47 | 'indirect' 48 | ]), 49 | hash: Joi 50 | .cid() 51 | .required() 52 | }).label('pin')) 53 | } 54 | },*/ 55 | plugins: { 56 | 'hapi-swagger': { 57 | id: 'repo.gc' 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/repo/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | require('./gc'), 5 | require('./stats') 6 | ] 7 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/repo/stats.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/repo', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.repo.stat() 18 | .then((stats) => { 19 | return { 20 | numObjects: Number(stats.numObjects), 21 | repoSize: Number(stats.repoSize), 22 | repoPath: stats.repoPath, 23 | version: Number(stats.version), 24 | storageMax: Number(stats.storageMax) 25 | } 26 | }) 27 | }, 28 | description: 'Get stats for the currently used repo', 29 | tags: ['api'], 30 | validate: { 31 | headers: { 32 | accept: Joi 33 | .string() 34 | .default(JSON) 35 | .valid([ 36 | JSON, 37 | EVERYTHING 38 | ]) 39 | }, 40 | options: { 41 | allowUnknown: true 42 | } 43 | }, 44 | response: { 45 | status: { 46 | 200: Joi.object({ 47 | numObjects: Joi 48 | .number() 49 | .integer() 50 | .min(0), 51 | repoSize: Joi 52 | .number() 53 | .integer() 54 | .min(0), 55 | repoPath: Joi 56 | .string() 57 | .required(), 58 | version: Joi 59 | .number() 60 | .integer() 61 | .min(0), 62 | storageMax: Joi 63 | .number() 64 | .integer() 65 | .min(0) 66 | }).label('repo-stats') 67 | } 68 | }, 69 | plugins: { 70 | 'hapi-swagger': { 71 | id: 'repo.stats' 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/add-filter.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-http/1c6f93780f749e05b0894f1a7d98bdb2bcc4d20d/packages/js-rest-server/routes/swarm/add-filter.js -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/addrs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/swarm/connections', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.swarm.filters() 18 | }, 19 | description: 'List of known addresses of each peer connected', 20 | tags: ['api'], 21 | validate: { 22 | headers: { 23 | accept: Joi 24 | .string() 25 | .default(JSON) 26 | .valid([ 27 | JSON, 28 | EVERYTHING 29 | ]) 30 | }, 31 | options: { 32 | allowUnknown: true 33 | } 34 | }, 35 | /*response: { 36 | status: { 37 | 200: Joi.object({ 38 | numObjects: Joi 39 | .number() 40 | .integer() 41 | .min(0), 42 | repoSize: Joi 43 | .number() 44 | .integer() 45 | .min(0), 46 | repoPath: Joi 47 | .string() 48 | .required(), 49 | version: Joi 50 | .number() 51 | .integer() 52 | .min(0), 53 | storageMax: Joi 54 | .number() 55 | .integer() 56 | .min(0) 57 | }).label('repo-stats') 58 | } 59 | },*/ 60 | plugins: { 61 | 'hapi-swagger': { 62 | id: 'swarm.addrs' 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/connect.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/swarm/connections', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.swarm.filters() 18 | }, 19 | description: 'Open a connection to a given address', 20 | tags: ['api'], 21 | validate: { 22 | payload: Joi.object({ 23 | address: Joi 24 | .multiaddr() 25 | .required() 26 | }).label('swam-connect-to-peer-payload'), 27 | headers: { 28 | accept: Joi 29 | .string() 30 | .default(JSON) 31 | .valid([ 32 | JSON, 33 | EVERYTHING 34 | ]) 35 | }, 36 | options: { 37 | allowUnknown: true 38 | } 39 | }, 40 | /*response: { 41 | status: { 42 | 200: Joi.object({ 43 | numObjects: Joi 44 | .number() 45 | .integer() 46 | .min(0), 47 | repoSize: Joi 48 | .number() 49 | .integer() 50 | .min(0), 51 | repoPath: Joi 52 | .string() 53 | .required(), 54 | version: Joi 55 | .number() 56 | .integer() 57 | .min(0), 58 | storageMax: Joi 59 | .number() 60 | .integer() 61 | .min(0) 62 | }).label('repo-stats') 63 | } 64 | },*/ 65 | plugins: { 66 | 'hapi-swagger': { 67 | id: 'swarm.connect' 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/disconnect.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'DELETE', 14 | path: '/swarm/connections/{address}', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.swarm.filters() 18 | }, 19 | description: 'Close a connection to a given address', 20 | tags: ['api'], 21 | validate: { 22 | params: { 23 | address: Joi 24 | .multiaddr() 25 | .required() 26 | .description('The address of the peer to disconnect from') 27 | }, 28 | headers: { 29 | accept: Joi 30 | .string() 31 | .default(JSON) 32 | .valid([ 33 | JSON, 34 | EVERYTHING 35 | ]) 36 | }, 37 | options: { 38 | allowUnknown: true 39 | } 40 | }, 41 | /*response: { 42 | status: { 43 | 200: Joi.object({ 44 | numObjects: Joi 45 | .number() 46 | .integer() 47 | .min(0), 48 | repoSize: Joi 49 | .number() 50 | .integer() 51 | .min(0), 52 | repoPath: Joi 53 | .string() 54 | .required(), 55 | version: Joi 56 | .number() 57 | .integer() 58 | .min(0), 59 | storageMax: Joi 60 | .number() 61 | .integer() 62 | .min(0) 63 | }).label('repo-stats') 64 | } 65 | },*/ 66 | plugins: { 67 | 'hapi-swagger': { 68 | id: 'swarm.disconnect' 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/filters.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/swarm/filters', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.swarm.filters() 18 | }, 19 | description: 'Display current multiaddr filters', 20 | notes: [ 21 | 'Filters are a way to set up rules for the network connections established' 22 | ], 23 | tags: ['api'], 24 | validate: { 25 | headers: { 26 | accept: Joi 27 | .string() 28 | .default(JSON) 29 | .valid([ 30 | JSON, 31 | EVERYTHING 32 | ]) 33 | }, 34 | options: { 35 | allowUnknown: true 36 | } 37 | }, 38 | /*response: { 39 | status: { 40 | 200: Joi.object({ 41 | numObjects: Joi 42 | .number() 43 | .integer() 44 | .min(0), 45 | repoSize: Joi 46 | .number() 47 | .integer() 48 | .min(0), 49 | repoPath: Joi 50 | .string() 51 | .required(), 52 | version: Joi 53 | .number() 54 | .integer() 55 | .min(0), 56 | storageMax: Joi 57 | .number() 58 | .integer() 59 | .min(0) 60 | }).label('repo-stats') 61 | } 62 | },*/ 63 | plugins: { 64 | 'hapi-swagger': { 65 | id: 'swarm.filters' 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/index.js: -------------------------------------------------------------------------------- 1 | 'use strict', 2 | 3 | module.exports = [ 4 | //require('./add-filter'), 5 | require('./addrs'), 6 | require('./connect'), 7 | require('./disconnect'), 8 | //require('./filters'), 9 | require('./peers'), 10 | //require('./remove-filter') 11 | require('./ping'), 12 | require('./peer') 13 | ] 14 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/peer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/swarm/peer', 15 | options: { 16 | handler: (request, reply) => { 17 | return Promise.all([ 18 | request.server.app.ipfs.id(), 19 | request.server.app.ipfs.version() 20 | ]).then(([id, version]) => { 21 | id.version = version 22 | return { 23 | id: id.id, 24 | publicKey: id.publicKey, 25 | addresses: id.addresses, 26 | agentVersion: id.agentVersion, 27 | protocolVersion: id.protocolVersion, 28 | repoVersion: version.repo 29 | } 30 | }) 31 | }, 32 | description: 'Returns information about this peer', 33 | tags: ['api'], 34 | validate: { 35 | headers: { 36 | accept: Joi.string() 37 | .default(JSON) 38 | .valid([ 39 | JSON, 40 | EVERYTHING 41 | ]) 42 | }, 43 | options: { 44 | allowUnknown: true 45 | } 46 | }, 47 | response: { 48 | status: { 49 | 200: Joi.object({ 50 | id: Joi 51 | .peerId() 52 | .required(), 53 | publicKey: Joi 54 | .string() 55 | .required(), 56 | addresses: Joi 57 | .array() 58 | .required() 59 | .items(Joi.multiaddr()), 60 | agentVersion: Joi 61 | .string() 62 | .required(), 63 | protocolVersion: Joi 64 | .string() 65 | .required(), 66 | repoVersion: Joi.number() 67 | }).label('peer') 68 | } 69 | }, 70 | plugins: { 71 | 'hapi-swagger': { 72 | id: 'swarm.info' 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/peers.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'GET', 14 | path: '/swarm/peers', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.swarm.peers({ 18 | verbose: true 19 | }) 20 | .then(peers => { 21 | return peers.map(peer => { 22 | const json = peer.peer.toJSON() 23 | 24 | return { 25 | id: json.id, 26 | address: peer.addr.toString('utf8'), 27 | publicKey: json.pubKey, 28 | latency: peer.latency 29 | } 30 | }) 31 | }) 32 | }, 33 | description: 'List out the peers that we have connections with', 34 | tags: ['api'], 35 | validate: { 36 | headers: { 37 | accept: Joi 38 | .string() 39 | .default(JSON) 40 | .valid([ 41 | JSON, 42 | EVERYTHING 43 | ]) 44 | }, 45 | options: { 46 | allowUnknown: true 47 | } 48 | }, 49 | response: { 50 | status: { 51 | 200: Joi 52 | .array() 53 | .items(Joi.object({ 54 | id: Joi 55 | .peerId() 56 | .required(), 57 | address: Joi 58 | .multiaddr() 59 | .required(), 60 | publicKey: Joi 61 | .string(), 62 | latency: Joi 63 | .any() 64 | }).label('remote-peer')).label('remote-peers') 65 | } 66 | }, 67 | plugins: { 68 | 'hapi-swagger': { 69 | id: 'swarm.peers' 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/ping.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { 4 | JSON, 5 | OCTET_STREAM, 6 | EVERYTHING 7 | } = require('../../utils/mime-types') 8 | const { 9 | Joi 10 | } = require('../../utils/validation') 11 | 12 | module.exports = { 13 | method: 'POST', 14 | path: '/swarm/peers/{peerId}/ping', 15 | options: { 16 | handler: (request, reply) => { 17 | return request.server.app.ipfs.ping(request.params.peerId, { 18 | count: request.payload.count 19 | }) 20 | }, 21 | description: 'Send echo request packets to IPFS hosts', 22 | notes: [ 23 | 'Note that not all ping response objects are "pongs".', 24 | 'A "pong" message can be identified by a truthy success property and an empty text property.', 25 | 'Other ping responses are failures or status updates.' 26 | ], 27 | tags: ['api'], 28 | validate: { 29 | params: { 30 | peerId: Joi 31 | .peerId() 32 | .required() 33 | }, 34 | payload: Joi.object({ 35 | count: Joi 36 | .number() 37 | .min(1) 38 | .max(50) 39 | .default(10) 40 | }).label('ping-peer-payload'), 41 | headers: { 42 | accept: Joi 43 | .string() 44 | .default(JSON) 45 | .valid([ 46 | JSON, 47 | EVERYTHING 48 | ]) 49 | }, 50 | options: { 51 | allowUnknown: true 52 | } 53 | }, 54 | response: { 55 | status: { 56 | 200: Joi 57 | .array() 58 | .items(Joi.object({ 59 | success: Joi 60 | .boolean(), 61 | time: Joi 62 | .number() 63 | .integer() 64 | .min(0), 65 | text: Joi 66 | .string() 67 | }).label('pong')).label('ping-responses') 68 | } 69 | }, 70 | plugins: { 71 | 'hapi-swagger': { 72 | id: 'swarm.ping', 73 | responses: { 74 | 404: { 75 | description: 'The DNS name could not be resolved' 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /packages/js-rest-server/routes/swarm/remove-filter.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-http/1c6f93780f749e05b0894f1a7d98bdb2bcc4d20d/packages/js-rest-server/routes/swarm/remove-filter.js -------------------------------------------------------------------------------- /packages/js-rest-server/utils/mime-types.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | JSON: 'application/json', 5 | OCTET_STREAM: 'application/octet-stream', 6 | EVERYTHING: '*/*', 7 | PEM: 'application/x-pem-file' 8 | } 9 | -------------------------------------------------------------------------------- /packages/js-rest-server/utils/transform-hash.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const CID = require('cids') 4 | 5 | module.exports = (hash, version = 1, base = 'base32') => { 6 | let cid = new CID(hash) 7 | 8 | if (version > 0) { 9 | cid = cid.toV1() 10 | } 11 | 12 | return cid.toBaseEncodedString(base) 13 | } 14 | -------------------------------------------------------------------------------- /packages/js-rest-server/utils/validation/cid-base.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | 5 | module.exports = Joi 6 | .description('Which number base to use when returning a CID') 7 | .valid(['base64', 'base32', 'base58btc']) 8 | .default('base32') 9 | -------------------------------------------------------------------------------- /packages/js-rest-server/utils/validation/cid-version.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Joi = require('joi') 4 | 5 | module.exports = Joi 6 | .description('Which CID version to use') 7 | .when('cidBase', { 8 | is: 'base58btc', 9 | then: Joi 10 | .number() 11 | .integer() 12 | .positive() 13 | .valid([0, 1]) 14 | .default(1), 15 | otherwise: Joi 16 | .number() 17 | .integer() 18 | .positive() 19 | .valid(1) 20 | .default(1) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/js-rest-server/utils/validation/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const CID = require('cids') 4 | const PeerId = require('peer-id') 5 | const Multiaddr = require('multiaddr') 6 | const cidBase = require('./cid-base') 7 | const cidVersion = require('./cid-version') 8 | 9 | const Joi = require('joi') 10 | .extend((joi) => ({ 11 | name: 'cid', 12 | base: joi.object(), 13 | language: { 14 | invalidCid: 'Invalid CID' 15 | }, 16 | coerce: function (value, state, options) { 17 | try { 18 | return new CID(value) 19 | } catch (error) { 20 | this.createError('cid.invalidCid', { v: value }, state, options) 21 | } 22 | } 23 | })) 24 | .extend((joi) => ({ 25 | name: 'peerId', 26 | base: joi.string(), 27 | language: { 28 | invalidPeerId: 'Invalid Peer ID' 29 | }, 30 | coerce: function (value, state, options) { 31 | try { 32 | value = value.toString() 33 | PeerId.createFromB58String(value) 34 | 35 | return value 36 | } catch (error) { 37 | this.createError('peerId.invalidPeerId', { v: value }, state, options) 38 | } 39 | } 40 | })) 41 | .extend((joi) => ({ 42 | name: 'multiaddr', 43 | base: joi.string(), 44 | language: { 45 | invalidMultiaddr: 'Invalid multiaddr' 46 | }, 47 | coerce: (value, state, options) => { 48 | try { 49 | value = value.toString() 50 | new Multiaddr(value) 51 | 52 | return value 53 | } catch (error) { 54 | this.createError('multiaddr.invalidMultiaddr', { v: value }, state, options) 55 | } 56 | } 57 | })) 58 | 59 | module.exports = { 60 | Joi, 61 | cidBase, 62 | cidVersion 63 | } 64 | --------------------------------------------------------------------------------