@surfaceapi/surface 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +24 -2
- package/index.js +29 -0
- package/package.json +11 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Canada Site Ops
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Surface clients
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://nova-otter-delta-cloud.grok.me)
|
|
4
|
+
|
|
5
|
+
Tiny clients for [Surface](https://nova-otter-delta-cloud.grok.me): usage-priced infrastructure for machine traffic (preflight, hop, pixel, inspect, MCP, badge). First 1M requests/month free.
|
|
6
|
+
|
|
7
|
+
- JavaScript: `npm install @surfaceapi/surface` ([clients/js](js))
|
|
8
|
+
- Python: `pip install surfaceapi` ([clients/python](python))
|
|
9
|
+
|
|
10
|
+
## MCP
|
|
11
|
+
Add Surface to any MCP client:
|
|
12
|
+
```json
|
|
13
|
+
{ "mcpServers": { "surface": { "url": "https://nova-otter-delta-cloud.grok.me/mcp" } } }
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## JavaScript
|
|
17
|
+
```js
|
|
18
|
+
const { Surface } = require( '@surfaceapi/surface');
|
|
19
|
+
const s = new Surface();
|
|
20
|
+
const { key } = await s.createKey(); // free key
|
|
21
|
+
const sk = new Surface({ apiKey: key });
|
|
22
|
+
console.log(await sk.preflight('https://example.com'));
|
|
23
|
+
console.log(await sk.inspect());
|
|
24
|
+
console.log(await sk.hop('abc123'));
|
|
25
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const DEFAULT_BASE = 'https://nova-otter-delta-cloud.grok.me';
|
|
3
|
+
class Surface {
|
|
4
|
+
constructor({ apiKey, baseUrl = DEFAULT_BASE, headers = {} } = {}) {
|
|
5
|
+
this.apiKey = apiKey; this.baseUrl = baseUrl.replace(/\/$/, ''); this.headers = headers;
|
|
6
|
+
}
|
|
7
|
+
async _req(method, path, body) {
|
|
8
|
+
const h = { 'user-agent': 'surfaceapi-js/0.1.0', ...this.headers };
|
|
9
|
+
if (this.apiKey) h.authorization = 'Bearer ' + this.apiKey;
|
|
10
|
+
if (body) h['content-type'] = 'application/json';
|
|
11
|
+
const r = await fetch(this.baseUrl + path, { method, headers: h, body: body ? JSON.stringify(body) : undefined, redirect: 'manual' });
|
|
12
|
+
const t = await r.text(); let data; try { data = JSON.parse(t); } catch { data = t; }
|
|
13
|
+
if (r.status >= 400) { const e = new Error('Surface ' + r.status); e.status = r.status; e.data = data; throw e; }
|
|
14
|
+
return { status: r.status, location: r.headers.get('location'), data };
|
|
15
|
+
}
|
|
16
|
+
/** Get a free API key (first 1M requests/month free). */
|
|
17
|
+
async createKey(opts = {}) { return (await this._req('POST', '/v1/keys', opts)).data; }
|
|
18
|
+
/** Preflight a URL: reachability, status, redirects, headers. */
|
|
19
|
+
async preflight(url) { return (await this._req('POST', '/v1/preflight', { url })).data; }
|
|
20
|
+
/** Inspect the calling request as Surface sees it. */
|
|
21
|
+
async inspect() { return (await this._req('GET', '/v1/inspect')).data; }
|
|
22
|
+
/** Resolve a hop short link; returns the redirect target. */
|
|
23
|
+
async hop(code) { const r = await this._req('GET', '/h/' + encodeURIComponent(code)); return { status: r.status, location: r.location }; }
|
|
24
|
+
/** Pixel URL for embedding. */
|
|
25
|
+
pixelUrl(code) { return this.baseUrl + '/px/' + encodeURIComponent(code); }
|
|
26
|
+
/** Usage for your key. */
|
|
27
|
+
async usage() { return (await this._req('GET', '/v1/usage')).data; }
|
|
28
|
+
}
|
|
29
|
+
module.exports = { Surface, DEFAULT_BASE };
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surfaceapi/surface",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tiny client for Surface: usage-priced infrastructure for machine traffic (preflight, hop, pixel, inspect, MCP).",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": ["index.js", "README.md"],
|
|
7
|
+
"engines": { "node": ">=18" },
|
|
8
|
+
"keywords": ["surface", "mcp", "agents", "preflight", "link-check", "pixel", "api"],
|
|
9
|
+
"author": "Surface / Canada Site Ops <canada.site.ops@gmail.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"homepage": "https://nova-otter-delta-cloud.grok.me",
|
|
12
|
+
"repository": { "type": "git", "url": "git+https://github.com/Surface-ops/surface.git", "directory": "clients/js" }
|
|
13
|
+
}
|