papermark 0.10.0 → 0.10.1
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/dist/index.js +96 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
5
4
|
import { Command as Command2 } from "commander";
|
|
6
5
|
|
|
7
6
|
// src/commands/analytics.ts
|
|
@@ -95,6 +94,86 @@ function getRuntime() {
|
|
|
95
94
|
return current;
|
|
96
95
|
}
|
|
97
96
|
|
|
97
|
+
// package.json
|
|
98
|
+
var package_default = {
|
|
99
|
+
name: "papermark",
|
|
100
|
+
version: "0.10.1",
|
|
101
|
+
description: "Command-line interface for Papermark \u2014 share documents, create data rooms, generate access links, and read analytics.",
|
|
102
|
+
license: "MIT",
|
|
103
|
+
homepage: "https://www.papermark.com",
|
|
104
|
+
repository: {
|
|
105
|
+
type: "git",
|
|
106
|
+
url: "git+https://github.com/papermark/papermark-cli.git"
|
|
107
|
+
},
|
|
108
|
+
bugs: {
|
|
109
|
+
url: "https://github.com/papermark/papermark-cli/issues"
|
|
110
|
+
},
|
|
111
|
+
keywords: [
|
|
112
|
+
"papermark",
|
|
113
|
+
"dataroom",
|
|
114
|
+
"datarooms",
|
|
115
|
+
"data room",
|
|
116
|
+
"virtual data room",
|
|
117
|
+
"document sharing",
|
|
118
|
+
"secure file sharing",
|
|
119
|
+
"access links",
|
|
120
|
+
"analytics",
|
|
121
|
+
"cli"
|
|
122
|
+
],
|
|
123
|
+
type: "module",
|
|
124
|
+
bin: {
|
|
125
|
+
papermark: "dist/index.js"
|
|
126
|
+
},
|
|
127
|
+
files: [
|
|
128
|
+
"dist",
|
|
129
|
+
"docs",
|
|
130
|
+
"skills",
|
|
131
|
+
"openai.yaml",
|
|
132
|
+
"README.md",
|
|
133
|
+
"LICENSE"
|
|
134
|
+
],
|
|
135
|
+
engines: {
|
|
136
|
+
node: ">=24"
|
|
137
|
+
},
|
|
138
|
+
scripts: {
|
|
139
|
+
build: "tsup",
|
|
140
|
+
dev: "tsx src/index.ts",
|
|
141
|
+
typecheck: "tsc --noEmit",
|
|
142
|
+
test: "vitest run",
|
|
143
|
+
"test:watch": "vitest",
|
|
144
|
+
changeset: "changeset",
|
|
145
|
+
version: "changeset version",
|
|
146
|
+
release: "npm run build && changeset publish",
|
|
147
|
+
prepublishOnly: "npm run build"
|
|
148
|
+
},
|
|
149
|
+
dependencies: {
|
|
150
|
+
chalk: "^5.3.0",
|
|
151
|
+
commander: "^14.0.3",
|
|
152
|
+
conf: "^13.0.1",
|
|
153
|
+
"mime-types": "^3.0.2",
|
|
154
|
+
oauth4webapi: "^3.8.5",
|
|
155
|
+
open: "^11.0.0",
|
|
156
|
+
ora: "^9.4.0",
|
|
157
|
+
prompts: "^2.4.2"
|
|
158
|
+
},
|
|
159
|
+
devDependencies: {
|
|
160
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
161
|
+
"@changesets/cli": "^2.31.0",
|
|
162
|
+
"@types/mime-types": "^3.0.1",
|
|
163
|
+
"@types/node": "^22.13.5",
|
|
164
|
+
"@types/prompts": "^2.4.9",
|
|
165
|
+
tsup: "^8.3.5",
|
|
166
|
+
tsx: "^4.21.0",
|
|
167
|
+
typescript: "^5.7.2",
|
|
168
|
+
vitest: "^4.1.5"
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/version.ts
|
|
173
|
+
var VERSION = package_default.version;
|
|
174
|
+
var CLIENT_ID = "cli";
|
|
175
|
+
var USER_AGENT = `papermark-cli/${VERSION} (node ${process.version}; ${process.platform} ${process.arch})`;
|
|
176
|
+
|
|
98
177
|
// src/client.ts
|
|
99
178
|
var ApiError = class extends Error {
|
|
100
179
|
code;
|
|
@@ -162,7 +241,15 @@ function buildUrl(path, query) {
|
|
|
162
241
|
async function request(path, opts = {}) {
|
|
163
242
|
const headers = {
|
|
164
243
|
Accept: "application/json",
|
|
165
|
-
...opts.headers ?? {}
|
|
244
|
+
...opts.headers ?? {},
|
|
245
|
+
// Identify the caller so the API can attribute usage to the CLI (vs the
|
|
246
|
+
// MCP server or raw HTTP) and the client version. Dedicated headers keep
|
|
247
|
+
// server-side parsing unambiguous; the User-Agent mirrors them for
|
|
248
|
+
// proxy/access logs. Set last so attribution can't be spoofed or dropped
|
|
249
|
+
// by caller-supplied headers.
|
|
250
|
+
"User-Agent": USER_AGENT,
|
|
251
|
+
"x-papermark-client": CLIENT_ID,
|
|
252
|
+
"x-papermark-client-version": VERSION
|
|
166
253
|
};
|
|
167
254
|
if (!opts.anonymous) {
|
|
168
255
|
const token = getToken();
|
|
@@ -206,7 +293,8 @@ async function request(path, opts = {}) {
|
|
|
206
293
|
debug("http", "network error after", `${Date.now() - started}ms`, String(err));
|
|
207
294
|
throw new NetworkError(url, err);
|
|
208
295
|
}
|
|
209
|
-
|
|
296
|
+
const requestId = res.headers.get("x-request-id") ?? "";
|
|
297
|
+
debug("http", method, url, `\u2192 ${res.status}`, requestId, `(${Date.now() - started}ms)`);
|
|
210
298
|
if (res.status === 204) return void 0;
|
|
211
299
|
const text = await res.text();
|
|
212
300
|
const parsed = text ? safeParseJson(text) : null;
|
|
@@ -657,7 +745,7 @@ import ora from "ora";
|
|
|
657
745
|
// src/oauth.ts
|
|
658
746
|
import * as oauth from "oauth4webapi";
|
|
659
747
|
import open from "open";
|
|
660
|
-
var
|
|
748
|
+
var CLIENT_ID2 = "papermark-cli";
|
|
661
749
|
var DEFAULT_SCOPES = [
|
|
662
750
|
"openid",
|
|
663
751
|
"offline_access",
|
|
@@ -698,7 +786,7 @@ async function requestDeviceAuthorization(as, scopes) {
|
|
|
698
786
|
);
|
|
699
787
|
}
|
|
700
788
|
const body = new URLSearchParams({
|
|
701
|
-
client_id:
|
|
789
|
+
client_id: CLIENT_ID2,
|
|
702
790
|
scope: scopes.join(" ")
|
|
703
791
|
});
|
|
704
792
|
const json2 = await postFormJson(
|
|
@@ -766,7 +854,7 @@ async function pollForToken(as, deviceCode, {
|
|
|
766
854
|
const body = new URLSearchParams({
|
|
767
855
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
768
856
|
device_code: deviceCode,
|
|
769
|
-
client_id:
|
|
857
|
+
client_id: CLIENT_ID2
|
|
770
858
|
});
|
|
771
859
|
let parsed;
|
|
772
860
|
try {
|
|
@@ -805,7 +893,7 @@ async function revokeToken(token) {
|
|
|
805
893
|
body: new URLSearchParams({
|
|
806
894
|
token,
|
|
807
895
|
token_type_hint: "access_token",
|
|
808
|
-
client_id:
|
|
896
|
+
client_id: CLIENT_ID2
|
|
809
897
|
})
|
|
810
898
|
});
|
|
811
899
|
return res.ok ? "revoked" : "failed";
|
|
@@ -3003,18 +3091,8 @@ More results: --cursor ${res.next_cursor}`) : out;
|
|
|
3003
3091
|
}
|
|
3004
3092
|
|
|
3005
3093
|
// src/index.ts
|
|
3006
|
-
function cliVersion() {
|
|
3007
|
-
try {
|
|
3008
|
-
const pkg = JSON.parse(
|
|
3009
|
-
readFileSync3(new URL("../package.json", import.meta.url), "utf8")
|
|
3010
|
-
);
|
|
3011
|
-
return pkg.version ?? "0.0.0";
|
|
3012
|
-
} catch {
|
|
3013
|
-
return "0.0.0";
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
3094
|
var program = new Command2();
|
|
3017
|
-
program.name("papermark").description("Papermark CLI \u2014 manage documents, links, and views").version(
|
|
3095
|
+
program.name("papermark").description("Papermark CLI \u2014 manage documents, links, and views").version(VERSION).option(
|
|
3018
3096
|
"--json",
|
|
3019
3097
|
"emit machine-readable JSON on stdout (auto-enabled when piped)"
|
|
3020
3098
|
).option(
|