@memberjunction/esignature 0.0.1 → 5.40.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/server/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AACxF,OAAO,EACH,sBAAsB,EAGtB,2BAA2B,GAE9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAyB5D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC1C,iBAAyB,EACzB,WAAqB,EACrB,QAA4B;IAE5B,MAAM,EAAE,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;IACzC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,eAAe,CAA0B,uBAAuB,EAAE,WAAW,CAAC,CAAC;IACxG,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,IAAI,GAAG,iBAAiB,MAAM,CAAC;IAChF,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,0BAA0B,CAAC;IAEnE,IAAI,OAAO,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QACjC,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAClF,CAAC;IAED,2CAA2C;IAC3C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AAqB,EACrB,QAA4B;IAE5B,MAAM,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC3E,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,sBAAsB,CAAC,QAAQ,CAAC,yBAAyB,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAG,sBAAsB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,MAAM,IAAI,QAAQ,CAAC;IAChC,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,6FAA6F,CAAC,CAAC;IACnH,CAAC;IACD,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './SignatureEngine.js';
2
+ export * from './util.js';
3
+ export * from './artifacts.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAKA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ // SERVER-SIDE PUBLIC API — imported via '@memberjunction/esignature/server'.
2
+ // Adds credential decryption + envelope-lifecycle persistence on top of the metadata cache.
3
+ // Depends on the server-only @memberjunction/credentials package, which is why these live behind
4
+ // the '/server' subpath. SignatureEngineBase (metadata-only) is exported from the root entry,
5
+ // '@memberjunction/esignature', NOT here — re-export it there to keep one source of truth.
6
+ export * from './SignatureEngine.js';
7
+ export * from './util.js';
8
+ export * from './artifacts.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4FAA4F;AAC5F,iGAAiG;AACjG,8FAA8F;AAC9F,2FAA2F;AAC3F,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { UserInfo } from '@memberjunction/core';
2
+ import { MJSignatureAccountEntity, MJSignatureProviderEntity } from '@memberjunction/core-entities';
3
+ import { BaseSignatureProvider } from '../BaseSignatureProvider.js';
4
+ /** Options for initializing a signature driver from an account + provider pair. */
5
+ export interface AccountSignatureDriverOptions {
6
+ /** The signature account entity (carries CredentialID + Configuration). */
7
+ accountEntity: MJSignatureAccountEntity;
8
+ /** The signature provider entity (carries ServerDriverKey + Configuration). */
9
+ providerEntity: MJSignatureProviderEntity;
10
+ /** Context user for DB operations and credential decryption. */
11
+ contextUser: UserInfo;
12
+ }
13
+ /**
14
+ * Resolve + initialize a signature provider driver for an account, using the Credential Engine.
15
+ *
16
+ * Mirrors MJStorage's `initializeDriverWithAccountCredentials`:
17
+ * 1. Resolve the driver by `provider.ServerDriverKey` via `MJGlobal.ClassFactory`.
18
+ * 2. Merge provider Configuration (defaults) + account Configuration (overrides) into the base config.
19
+ * 3. If the account has a CredentialID, decrypt it via the Credential Engine and overlay the values,
20
+ * wiring an `onTokenRefresh` callback that persists rotated tokens back via `updateCredential`.
21
+ * 4. Call `driver.initialize(...)`.
22
+ *
23
+ * Credential values take precedence over Configuration, matching the Storage merge order.
24
+ */
25
+ export declare function initializeDriverWithAccountCredentials(options: AccountSignatureDriverOptions): Promise<BaseSignatureProvider>;
26
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/server/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,mFAAmF;AACnF,MAAM,WAAW,6BAA6B;IAC1C,2EAA2E;IAC3E,aAAa,EAAE,wBAAwB,CAAC;IACxC,+EAA+E;IAC/E,cAAc,EAAE,yBAAyB,CAAC;IAC1C,gEAAgE;IAChE,WAAW,EAAE,QAAQ,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,sCAAsC,CACxD,OAAO,EAAE,6BAA6B,GACvC,OAAO,CAAC,qBAAqB,CAAC,CA0BhC"}
@@ -0,0 +1,94 @@
1
+ import { LogStatus } from '@memberjunction/core';
2
+ import { MJGlobal } from '@memberjunction/global';
3
+ import { CredentialEngine } from '@memberjunction/credentials';
4
+ import { BaseSignatureProvider } from '../BaseSignatureProvider.js';
5
+ /**
6
+ * Resolve + initialize a signature provider driver for an account, using the Credential Engine.
7
+ *
8
+ * Mirrors MJStorage's `initializeDriverWithAccountCredentials`:
9
+ * 1. Resolve the driver by `provider.ServerDriverKey` via `MJGlobal.ClassFactory`.
10
+ * 2. Merge provider Configuration (defaults) + account Configuration (overrides) into the base config.
11
+ * 3. If the account has a CredentialID, decrypt it via the Credential Engine and overlay the values,
12
+ * wiring an `onTokenRefresh` callback that persists rotated tokens back via `updateCredential`.
13
+ * 4. Call `driver.initialize(...)`.
14
+ *
15
+ * Credential values take precedence over Configuration, matching the Storage merge order.
16
+ */
17
+ export async function initializeDriverWithAccountCredentials(options) {
18
+ const { accountEntity, providerEntity, contextUser } = options;
19
+ const driver = MJGlobal.Instance.ClassFactory.CreateInstance(BaseSignatureProvider, providerEntity.ServerDriverKey);
20
+ if (!driver) {
21
+ throw new Error(`Failed to create signature driver for provider "${providerEntity.Name}" ` +
22
+ `with driver key "${providerEntity.ServerDriverKey}".`);
23
+ }
24
+ const baseConfig = buildBaseConfig(accountEntity, providerEntity);
25
+ if (accountEntity.CredentialID) {
26
+ await applyCredentialValues(driver, baseConfig, accountEntity, contextUser);
27
+ }
28
+ else {
29
+ await driver.initialize(baseConfig);
30
+ LogStatus(`[eSignature] Initialized account "${accountEntity.Name}" from Configuration only (no credential set).`);
31
+ }
32
+ return driver;
33
+ }
34
+ /** Build the non-secret base config: account identity + merged provider/account Configuration JSON. */
35
+ function buildBaseConfig(accountEntity, providerEntity) {
36
+ return {
37
+ accountId: accountEntity.ID,
38
+ accountName: accountEntity.Name,
39
+ ...parseConfiguration(providerEntity.Configuration, `provider "${providerEntity.Name}"`),
40
+ ...parseConfiguration(accountEntity.Configuration, `account "${accountEntity.Name}"`),
41
+ };
42
+ }
43
+ /** Decrypt the account's credential, overlay its values, and initialize the driver with token refresh. */
44
+ async function applyCredentialValues(driver, baseConfig, accountEntity, contextUser) {
45
+ await CredentialEngine.Instance.Config(false, contextUser);
46
+ const credentialEntity = CredentialEngine.Instance.getCredentialById(accountEntity.CredentialID);
47
+ if (!credentialEntity) {
48
+ throw new Error(`Credential with ID ${accountEntity.CredentialID} not found for account "${accountEntity.Name}".`);
49
+ }
50
+ const resolved = await CredentialEngine.Instance.getCredential(credentialEntity.Name, {
51
+ credentialId: accountEntity.CredentialID,
52
+ contextUser,
53
+ subsystem: 'eSignature',
54
+ });
55
+ const onTokenRefresh = buildTokenRefreshCallback(accountEntity, resolved.values, contextUser);
56
+ await driver.initialize({
57
+ ...baseConfig,
58
+ ...resolved.values,
59
+ onTokenRefresh,
60
+ });
61
+ }
62
+ /** Build a callback that persists rotated OAuth tokens back to the Credential Engine. */
63
+ function buildTokenRefreshCallback(accountEntity, currentValues, contextUser) {
64
+ return async (newRefreshToken, newAccessToken) => {
65
+ try {
66
+ const updatedValues = { ...currentValues, refreshToken: newRefreshToken };
67
+ if (newAccessToken) {
68
+ updatedValues.accessToken = newAccessToken;
69
+ }
70
+ await CredentialEngine.Instance.updateCredential(accountEntity.CredentialID, updatedValues, contextUser);
71
+ LogStatus(`[eSignature] Persisted refreshed tokens for account "${accountEntity.Name}".`);
72
+ }
73
+ catch (error) {
74
+ const message = error instanceof Error ? error.message : String(error);
75
+ console.error(`[eSignature] Failed to persist refreshed tokens for account "${accountEntity.Name}": ${message}. ` +
76
+ `Authentication may fail after server restart.`);
77
+ }
78
+ };
79
+ }
80
+ /** Parse a Configuration JSON string into an object; returns {} on null/invalid (logged). */
81
+ function parseConfiguration(configJson, label) {
82
+ if (!configJson) {
83
+ return {};
84
+ }
85
+ try {
86
+ const parsed = JSON.parse(configJson);
87
+ return parsed && typeof parsed === 'object' ? parsed : {};
88
+ }
89
+ catch {
90
+ LogStatus(`[eSignature] Ignoring invalid Configuration JSON on ${label}.`);
91
+ return {};
92
+ }
93
+ }
94
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/server/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAajE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CACxD,OAAsC;IAEtC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAE/D,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CACxD,qBAAqB,EACrB,cAAc,CAAC,eAAe,CACjC,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACX,mDAAmD,cAAc,CAAC,IAAI,IAAI;YACtE,oBAAoB,cAAc,CAAC,eAAe,IAAI,CAC7D,CAAC;IACN,CAAC;IAED,MAAM,UAAU,GAAG,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAA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KAAK,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAkC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACL,SAAS,CAAC,uDAAuD,KAAK,GAAG,CAAC,CAAC;QAC3E,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Normalized, provider-agnostic types for the MemberJunction eSignature primitive.
3
+ *
4
+ * These types form the contract between the engine and any concrete signature provider
5
+ * (DocuSign, Adobe Sign, Dropbox Sign, …). They contain NO MemberJunction data dependencies
6
+ * so the contract can be imported on the client as well as the server.
7
+ */
8
+ /**
9
+ * The full set of operations a signature provider may support. Core operations are always
10
+ * implemented; optional operations return a "not supported" result by default and are
11
+ * advertised via {@link BaseSignatureProvider.getSupportedOperations}.
12
+ */
13
+ export type SignatureOperation = 'CreateEnvelope' | 'GetEnvelopeStatus' | 'DownloadSignedDocument' | 'VoidEnvelope' | 'CreateEmbeddedSigningUrl' | 'ApplyTemplate' | 'ResendNotification' | 'ParseWebhookEvent' | 'VerifyWebhookSignature';
14
+ /**
15
+ * Normalized envelope lifecycle status. Each provider maps its own status vocabulary onto
16
+ * this set. `Unknown` is used when a provider returns a status we don't recognize.
17
+ */
18
+ export type EnvelopeStatus = 'Draft' | 'Sent' | 'Delivered' | 'Signed' | 'Completed' | 'Declined' | 'Voided' | 'Unknown';
19
+ /**
20
+ * Callback a provider invokes when it refreshes OAuth tokens, so the engine can persist the
21
+ * new tokens back to the Credential Engine. Mirrors the Storage subsystem's TokenRefreshCallback.
22
+ */
23
+ export type SignatureTokenRefreshCallback = (newRefreshToken: string, newAccessToken?: string) => Promise<void>;
24
+ /**
25
+ * Configuration handed to a provider's {@link BaseSignatureProvider.initialize}. It is the merge
26
+ * of (provider defaults + account overrides + decrypted credential values), assembled by the
27
+ * engine. Providers read whatever keys they need; unknown keys are ignored.
28
+ */
29
+ export interface SignatureProviderConfig {
30
+ /** The MJ: Signature Accounts.ID this provider instance is bound to, if any. */
31
+ accountId?: string;
32
+ /** Human-readable account name, for logging. */
33
+ accountName?: string;
34
+ /** Invoked by the provider after an OAuth token refresh so the engine can persist tokens. */
35
+ onTokenRefresh?: SignatureTokenRefreshCallback;
36
+ /**
37
+ * Shared secret used to verify inbound webhook signatures (e.g. DocuSign Connect HMAC,
38
+ * Dropbox Sign / PandaDoc callback HMAC). Lives in the account's encrypted MJ: Credentials row
39
+ * alongside the other provider secrets — never an environment variable. When absent, strict
40
+ * webhook verification fails closed (the engine rejects the event).
41
+ */
42
+ connectHmacKey?: string;
43
+ /** Provider-specific config + decrypted credential values (integrationKey, privateKey, …). */
44
+ [key: string]: unknown;
45
+ }
46
+ /** A signer to be added to an envelope. */
47
+ export interface SignatureRecipientInput {
48
+ email: string;
49
+ name?: string;
50
+ /** Signing order; lower routes first. Defaults to 1 per recipient if omitted. */
51
+ routingOrder?: number;
52
+ /** Template role name, when using {@link BaseSignatureProvider.ApplyTemplate}. */
53
+ role?: string;
54
+ }
55
+ /** A document to include in an envelope. */
56
+ export interface SignatureDocumentInput {
57
+ bytes: Buffer;
58
+ filename: string;
59
+ /** MIME type, e.g. application/pdf. */
60
+ contentType: string;
61
+ /** Provider document id; the engine assigns a sequential id when omitted. */
62
+ documentId?: string;
63
+ }
64
+ /** Request to create (and optionally send) a signature envelope. */
65
+ export interface CreateEnvelopeRequest {
66
+ /** Email subject / envelope title. */
67
+ title: string;
68
+ message?: string;
69
+ documents: SignatureDocumentInput[];
70
+ recipients: SignatureRecipientInput[];
71
+ /** true → send immediately ('sent'); false → create as draft ('created'). Defaults to true. */
72
+ sendImmediately?: boolean;
73
+ /** Provider custom fields / envelope metadata. */
74
+ metadata?: Record<string, string>;
75
+ }
76
+ /** Per-recipient status snapshot returned by {@link BaseSignatureProvider.GetEnvelopeStatus}. */
77
+ export interface RecipientStatus {
78
+ email: string;
79
+ name?: string;
80
+ status: EnvelopeStatus;
81
+ /** Provider recipient id, for correlation. */
82
+ externalRecipientId?: string;
83
+ /** ISO timestamp the recipient signed, when applicable. */
84
+ signedAt?: string;
85
+ }
86
+ /** Result of creating an envelope. */
87
+ export interface EnvelopeResult {
88
+ Success: boolean;
89
+ externalEnvelopeId?: string;
90
+ status?: EnvelopeStatus;
91
+ /** When the provider returns an inline signing URL (embedded flows). */
92
+ signingUrl?: string;
93
+ ErrorMessage?: string;
94
+ }
95
+ /** Result of querying envelope status. */
96
+ export interface EnvelopeStatusResult {
97
+ Success: boolean;
98
+ status: EnvelopeStatus;
99
+ recipients?: RecipientStatus[];
100
+ ErrorMessage?: string;
101
+ }
102
+ /** Result of downloading the executed/signed document. */
103
+ export interface SignedDocumentResult {
104
+ Success: boolean;
105
+ document?: {
106
+ bytes: Buffer;
107
+ filename: string;
108
+ contentType: string;
109
+ };
110
+ ErrorMessage?: string;
111
+ }
112
+ /** Generic result for operations that only succeed or fail (void, resend, …). */
113
+ export interface OperationResult {
114
+ Success: boolean;
115
+ ErrorMessage?: string;
116
+ }
117
+ /** Request to create an embedded (in-app) signing URL for a recipient. */
118
+ export interface EmbeddedSigningRequest {
119
+ externalEnvelopeId: string;
120
+ recipientEmail: string;
121
+ recipientName?: string;
122
+ /** URL the provider redirects to after the signing ceremony completes. */
123
+ returnUrl: string;
124
+ }
125
+ /** Result of creating an embedded signing URL. */
126
+ export interface SigningUrlResult {
127
+ Success: boolean;
128
+ signingUrl?: string;
129
+ ErrorMessage?: string;
130
+ }
131
+ /** Request to create an envelope from a provider-hosted template. */
132
+ export interface TemplateEnvelopeRequest {
133
+ /** Provider template identifier. */
134
+ templateId: string;
135
+ title: string;
136
+ message?: string;
137
+ /** Recipients keyed by the template's role names. */
138
+ recipients: SignatureRecipientInput[];
139
+ sendImmediately?: boolean;
140
+ metadata?: Record<string, string>;
141
+ }
142
+ /**
143
+ * Outcome of {@link BaseSignatureProvider.VerifyWebhookSignature}. Three-state so the engine can
144
+ * distinguish "no secret configured" (verification not possible) from "configured but the signature
145
+ * didn't match" — enabling a verify-if-configured policy:
146
+ * - `Verified` — a secret is configured and the signature matched. Accept.
147
+ * - `Failed` — a secret is configured but the signature was missing/invalid. **Reject.**
148
+ * - `NotConfigured` — no secret is configured, so authenticity can't be checked. Accept with a
149
+ * logged warning (the endpoint still functions during setup; tightens to
150
+ * strict automatically once a key is set).
151
+ */
152
+ export type WebhookVerificationResult = 'Verified' | 'Failed' | 'NotConfigured';
153
+ /**
154
+ * A normalized inbound webhook event (DocuSign Connect, Adobe events, …) after the driver has
155
+ * verified the payload signature/HMAC and mapped it onto our vocabulary. Drivers return `null`
156
+ * from {@link BaseSignatureProvider.ParseWebhookEvent} for payloads they don't handle.
157
+ */
158
+ export interface NormalizedSignatureEvent {
159
+ externalEnvelopeId: string;
160
+ status: EnvelopeStatus;
161
+ /** ISO timestamp the event occurred. */
162
+ occurredAt: string;
163
+ /** Original payload, retained for audit. */
164
+ raw: unknown;
165
+ }
166
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,wBAAwB,GACxB,cAAc,GACd,0BAA0B,GAC1B,eAAe,GACf,oBAAoB,GACpB,mBAAmB,GACnB,wBAAwB,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,cAAc,GACpB,OAAO,GACP,MAAM,GACN,WAAW,GACX,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhH;;;;GAIG;AACH,MAAM,WAAW,uB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AU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,UAAU,EAAE,uBAAuB,EAAE,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,QAAQ,GAAG,eAAe,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,GAAG,EAAE,OAAO,CAAC;CAChB"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Normalized, provider-agnostic types for the MemberJunction eSignature primitive.
3
+ *
4
+ * These types form the contract between the engine and any concrete signature provider
5
+ * (DocuSign, Adobe Sign, Dropbox Sign, …). They contain NO MemberJunction data dependencies
6
+ * so the contract can be imported on the client as well as the server.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json CHANGED
@@ -1,10 +1,47 @@
1
1
  {
2
2
  "name": "@memberjunction/esignature",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @memberjunction/esignature",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "version": "5.40.1",
4
+ "description": "MemberJunction eSignature primitive — pluggable provider contract and normalized types for sending documents for electronic signature (DocuSign, Adobe Sign, …). The optional server engine is exposed via the '@memberjunction/esignature/server' subpath.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./server": {
14
+ "types": "./dist/server/index.d.ts",
15
+ "default": "./dist/server/index.js"
16
+ }
17
+ },
18
+ "typesVersions": {
19
+ "*": {
20
+ "server": [
21
+ "dist/server/index.d.ts"
22
+ ]
23
+ }
24
+ },
25
+ "files": [
26
+ "/dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc && tsc-alias -f",
30
+ "watch": "tsc -w",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "test:coverage": "vitest run --coverage"
34
+ },
35
+ "license": "ISC",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/MemberJunction/MJ"
39
+ },
40
+ "dependencies": {
41
+ "@memberjunction/global": "5.40.1",
42
+ "@memberjunction/core": "5.40.1",
43
+ "@memberjunction/core-entities": "5.40.1",
44
+ "@memberjunction/credentials": "5.40.1",
45
+ "@memberjunction/storage": "5.40.1"
46
+ }
10
47
  }
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # @memberjunction/esignature
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@memberjunction/esignature`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**