Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe08bef300 | |||
| 80f5439669 | |||
| 0c125795f7 | |||
| 8ee3aa41a0 | |||
| a08d67c8df | |||
| ff877c6843 |
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartsign",
|
"name": "@push.rocks/smartsign",
|
||||||
"version": "1.0.2",
|
"version": "1.0.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "sign documents",
|
"description": "sign documents",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -21,7 +21,13 @@
|
|||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^20.8.7"
|
"@types/node": "^20.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"@push.rocks/smartfile": "^11.0.4",
|
||||||
|
"@push.rocks/smartpdf": "^3.0.16",
|
||||||
|
"@push.rocks/smartshell": "^3.0.3",
|
||||||
|
"@signpdf/signer-p12": "^3.1.0",
|
||||||
|
"@signpdf/signpdf": "^3.1.0"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://gitlab.com/push.rocks/smartsign.git"
|
"url": "git+https://gitlab.com/push.rocks/smartsign.git"
|
||||||
|
|||||||
377
pnpm-lock.yaml
generated
377
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -14,13 +14,16 @@ PRIVATE_KEY="$CERT_DIR/private.key"
|
|||||||
CERTIFICATE="$CERT_DIR/certificate.crt"
|
CERTIFICATE="$CERT_DIR/certificate.crt"
|
||||||
P12_CERTIFICATE="$CERT_DIR/certificate.p12"
|
P12_CERTIFICATE="$CERT_DIR/certificate.p12"
|
||||||
|
|
||||||
|
# Certificate subject details
|
||||||
|
SUBJECT="/C=US/ST=California/L=San Francisco/O=Your Company/OU=Your Department/CN=www.yourdomain.com"
|
||||||
|
|
||||||
# Generate a private key
|
# Generate a private key
|
||||||
openssl genpkey -algorithm RSA -out "$PRIVATE_KEY" -pkeyopt rsa_keygen_bits:2048
|
openssl genpkey -algorithm RSA -out "$PRIVATE_KEY" -pkeyopt rsa_keygen_bits:2048
|
||||||
|
|
||||||
# Create a self-signed certificate
|
# Create a self-signed certificate with no prompts
|
||||||
openssl req -new -x509 -days 365 -key "$PRIVATE_KEY" -out "$CERTIFICATE"
|
openssl req -new -x509 -days 365 -key "$PRIVATE_KEY" -out "$CERTIFICATE" -subj "$SUBJECT"
|
||||||
|
|
||||||
# Convert to P12 format
|
# Convert to P12 format
|
||||||
openssl pkcs12 -export -out "$P12_CERTIFICATE" -inkey "$PRIVATE_KEY" -in "$CERTIFICATE"
|
openssl pkcs12 -export -out "$P12_CERTIFICATE" -inkey "$PRIVATE_KEY" -in "$CERTIFICATE" -passout pass:YourPassword
|
||||||
|
|
||||||
echo "P12 certificate generated at $P12_CERTIFICATE"
|
echo "P12 certificate generated at $P12_CERTIFICATE"
|
||||||
|
|||||||
26
test/test.ts
26
test/test.ts
@@ -1,8 +1,26 @@
|
|||||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartsign from '../ts/index.js'
|
import * as smartsign from '../ts/index.js';
|
||||||
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.preTask('create signing certificate', async () => {
|
||||||
console.log(smartsign)
|
const certExists = await smartfile.fs.fileExists('./.nogit/certificate.p12');
|
||||||
|
console.log('certExists:', certExists);
|
||||||
|
|
||||||
|
if (!certExists) {
|
||||||
|
const smartshellInstance = new smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
});
|
||||||
|
await smartshellInstance.exec(`bash -x ./scripts/create.p12.sh`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.start()
|
let testSmartSign: smartsign.SmartSign;
|
||||||
|
|
||||||
|
tap.test('should create a new SmartSign instance', async () => {
|
||||||
|
const certSmartfile = await smartfile.SmartFile.fromFilePath('./.nogit/certificate.p12');
|
||||||
|
testSmartSign = new smartsign.SmartSign(certSmartfile.contentBuffer);
|
||||||
|
expect(testSmartSign).toBeInstanceOf(smartsign.SmartSign);
|
||||||
|
})
|
||||||
|
|
||||||
|
await tap.start();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartsign',
|
name: '@push.rocks/smartsign',
|
||||||
version: '1.0.2',
|
version: '1.0.5',
|
||||||
description: 'sign documents'
|
description: 'sign documents'
|
||||||
}
|
}
|
||||||
|
|||||||
13
ts/classes.envelope.ts
Normal file
13
ts/classes.envelope.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import type { SmartSign } from './classes.smartsign.js';
|
||||||
|
import * as plugins from './smartsign.plugins.js';
|
||||||
|
|
||||||
|
export class SigningEnvelope {
|
||||||
|
public pdf: plugins.smartpdf.IPdf;
|
||||||
|
constructor(smartsignRef: SmartSign, originalPdf: plugins.smartpdf.IPdf) {
|
||||||
|
this.pdf = originalPdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
exportSignedPdf() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
22
ts/classes.smartsign.ts
Normal file
22
ts/classes.smartsign.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { SigningEnvelope } from './classes.envelope.js';
|
||||||
|
import * as plugins from './smartsign.plugins.js';
|
||||||
|
|
||||||
|
export class SmartSign {
|
||||||
|
public p12Cert: Buffer;
|
||||||
|
public smartpdfInstance: plugins.smartpdf.SmartPdf;
|
||||||
|
constructor(p12CertBuffer: Buffer) {
|
||||||
|
this.p12Cert = p12CertBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async start() {
|
||||||
|
this.smartpdfInstance = new plugins.smartpdf.SmartPdf();
|
||||||
|
await this.smartpdfInstance.start();
|
||||||
|
}
|
||||||
|
public async stop() {
|
||||||
|
await this.smartpdfInstance.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async createEnvelopeFromPdf(pdfArg: plugins.smartpdf.IPdf) {
|
||||||
|
return new SigningEnvelope(this, pdfArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1 @@
|
|||||||
import * as plugins from './smartsign.plugins.js';
|
export * from './classes.smartsign.js';
|
||||||
|
|
||||||
export let demoExport = 'Hi there! :) This is an exported string';
|
|
||||||
@@ -1,4 +1,15 @@
|
|||||||
const removeme = {};
|
// @push.rocks scope
|
||||||
|
import * as smartpdf from '@push.rocks/smartpdf';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
removeme
|
smartpdf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// thirdparty scope
|
||||||
|
import * as signpdf from '@signpdf/signpdf';
|
||||||
|
import * as signerP12 from '@signpdf/signer-p12';
|
||||||
|
|
||||||
|
export {
|
||||||
|
signpdf,
|
||||||
|
signerP12,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user