@formizeflow/sdk 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 +91 -2
- package/dist/index.cjs +1874 -0
- package/dist/index.d.cts +5582 -0
- package/dist/index.d.ts +5582 -0
- package/dist/index.js +1751 -0
- package/dist/pgp-EDC744IM.js +28 -0
- package/package.json +52 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/pgp.ts
|
|
2
|
+
import * as openpgp from "openpgp";
|
|
3
|
+
var MAX_PGP_KEY = 16e3;
|
|
4
|
+
async function parsePgpPublicKey(armored) {
|
|
5
|
+
if (typeof armored !== "string" || armored.length > MAX_PGP_KEY) throw new Error("PGP key is too large");
|
|
6
|
+
if (/PRIVATE KEY BLOCK/.test(armored)) throw new Error("That is a private key. Paste the public key only");
|
|
7
|
+
const key = await openpgp.readKey({ armoredKey: armored });
|
|
8
|
+
if (key.isPrivate()) throw new Error("That is a private key. Paste the public key only");
|
|
9
|
+
await key.getEncryptionKey();
|
|
10
|
+
return { fingerprint: key.getFingerprint().toUpperCase(), userIds: key.getUserIDs() };
|
|
11
|
+
}
|
|
12
|
+
async function encryptPgp(armoredPublicKey, value) {
|
|
13
|
+
const encryptionKeys = await openpgp.readKey({ armoredKey: armoredPublicKey });
|
|
14
|
+
const message = await openpgp.createMessage({ text: JSON.stringify(value) });
|
|
15
|
+
return await openpgp.encrypt({ message, encryptionKeys, format: "armored" });
|
|
16
|
+
}
|
|
17
|
+
async function decryptPgp(armoredPrivateKey, armoredMessage, passphrase) {
|
|
18
|
+
let privateKey = await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey });
|
|
19
|
+
if (!privateKey.isDecrypted()) privateKey = await openpgp.decryptKey({ privateKey, passphrase: passphrase ?? "" });
|
|
20
|
+
const { data } = await openpgp.decrypt({ message: await openpgp.readMessage({ armoredMessage }), decryptionKeys: privateKey });
|
|
21
|
+
return JSON.parse(String(data));
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
MAX_PGP_KEY,
|
|
25
|
+
decryptPgp,
|
|
26
|
+
encryptPgp,
|
|
27
|
+
parsePgpPublicKey
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formizeflow/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed client for the FormFlow REST API: forms, submissions, experiments, onboarding decisions and webhook verification.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/formizeflow/formflow-js.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/formizeflow/formflow-js#readme",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external openpgp",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.10.0",
|
|
37
|
+
"tsup": "^8.3.0",
|
|
38
|
+
"typescript": "^5.7.0",
|
|
39
|
+
"vitest": "^3.0.0",
|
|
40
|
+
"openpgp": "6.3.2"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"openpgp": "^6.3.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"openpgp": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|