@uveysservetoglu/kobil-sign 2.0.0 → 3.0.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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @uveysservetoglu/kobil-sign
2
2
 
3
- KOBIL digital signature client for Node.js / TypeScript, with automatic OAuth token management.
3
+ KOBIL PDF signature client for Node.js / TypeScript — the MiniApp API's
4
+ `/v1/messages/sendPdfSignature` (default) or the legacy mPower signature API — with automatic OAuth
5
+ token management.
4
6
 
5
7
  ```bash
6
8
  npm install @uveysservetoglu/kobil-sign
@@ -9,8 +11,8 @@ npm install @uveysservetoglu/kobil-sign
9
11
  ```ts
10
12
  import { SignClient } from "@uveysservetoglu/kobil-sign";
11
13
 
12
- // OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, MPOWER_BASE and MPOWER_TENANT come from
13
- // the environment; only the callback is app-specific.
14
+ // OIDC_ISSUER, OIDC_CLIENT_ID and OIDC_CLIENT_SECRET (+ MPOWER_BASE, MPOWER_TENANT in legacy mode)
15
+ // come from the environment; only the callback is app-specific.
14
16
  const sign = new SignClient({
15
17
  defaultCallbackUrl: "https://yourapi.com/signature-callback",
16
18
  });
@@ -22,36 +24,60 @@ const res = await sign.initiatePdfSignature({
22
24
  messageText: "Please sign here",
23
25
  position: { pageNumber: 1, bottomLeftX: 59, bottomLeftY: 89, topRightX: 85, topRightY: 96 },
24
26
  });
25
- // res.messageId, res.instanceId
27
+ // res.messageId, plus res.createdAt and res.file (miniapp) or res.instanceId (legacy)
26
28
  ```
27
29
 
28
- `{TENANT}` is filled from `tenantName`, `{USER_ID}` from the call; `/signature` is appended.
30
+ ## Where the signature goes
29
31
 
30
- ## Environment
32
+ The two APIs describe the signature box differently. Either form works in either mode — the client
33
+ converts it:
31
34
 
32
- | Variable | Meaning |
33
- |---|---|
34
- | `OIDC_ISSUER` | Realm issuer URL; the token endpoint is derived from it. |
35
- | `OIDC_CLIENT_ID` / `OIDC_CLIENT_SECRET` | Client credentials. The id is also the default `serviceUuid`. |
36
- | `MPOWER_BASE` | mPower origin — signing shares it with chat. `{base}/auth/realms/{TENANT}/mpower/v1/users/{USER_ID}` is derived from it. |
37
- | `MPOWER_TENANT` | Tenant/realm substituted for `{TENANT}`. |
35
+ | Form | Units | Origin | Fields |
36
+ |---|---|---|---|
37
+ | `SignaturePosition` (legacy) | **integer percent** of the page, 0–100 | bottom-left | `pageNumber`, `bottomLeftX/Y`, `topRightX/Y` |
38
+ | `SignatureArea` (MiniApp) | fraction of the page, 0.0–1.0 | top-left | `page`, `left`, `top`, `width`, `height` |
38
39
 
39
- Pass `signBaseUrl` or `tenantName` to override. These are the names the SuperApp emulator publishes at
40
- `/__superapp/control/env`.
40
+ They are not PDF points. `toSignatureArea` / `toSignaturePosition` convert explicitly; legacy mode
41
+ rounds to whole percentages, because the legacy platform rejects anything else.
41
42
 
42
- ### How it maps to the API
43
+ **Several signers (miniapp mode):** pass `signatures` instead of `position` — 1–20 fields, each with
44
+ its own `signeeUserId` (default: `userId`):
43
45
 
44
- `POST {signBaseUrl}/signature` as `multipart/form-data`:
46
+ ```ts
47
+ await sign.initiatePdfSignature({
48
+ userId,
49
+ file: pdfBytes,
50
+ messageText: "Please both sign",
51
+ signatures: [
52
+ { position: { page: 1, left: 0.1, top: 0.85, width: 0.3, height: 0.06 } },
53
+ { signeeUserId: otherUserId, position: { page: 1, left: 0.6, top: 0.85, width: 0.3, height: 0.06 } },
54
+ ],
55
+ });
56
+ ```
57
+
58
+ Legacy mode takes exactly one field, signed by `userId`.
59
+
60
+ ## API mode
61
+
62
+ Leave `apiMode` unset (or `KOBIL_API_MODE` empty) for the MiniApp API; pass `"legacy"` for mPower.
63
+ See `@uveysservetoglu/kobil-core` for the shared settings.
64
+
65
+ | | Miniapp (default) | Legacy |
66
+ |---|---|---|
67
+ | Request | `POST /v1/messages/sendPdfSignature`, multipart `file` + JSON `message` | `POST {signBaseUrl}/signature`, multipart `signatureFile` + `signatureData` |
68
+ | `messageText` | required | optional |
69
+ | Callback | optional — omit for the MiniApp's global callback | `callbackUrl` / `defaultCallbackUrl` |
70
+ | Push | `push` bundled with the request | ignored |
45
71
 
46
- - `signatureFile` — the PDF bytes (`application/pdf`)
47
- - `signatureData` — JSON: `version`, `pageNumber`, `bottomLeft*/topRight*Coordinate`,
48
- `serviceUuid`, `messageText`, `callbackUrl`
72
+ Legacy mode only: the endpoint is derived from `MPOWER_BASE`
73
+ (`{base}/auth/realms/{TENANT}/mpower/v1/users/{USER_ID}`, with `/signature` appended); `{TENANT}` is
74
+ filled from `tenantName` (`MPOWER_TENANT`). Pass `signBaseUrl` or `tenantName` to override.
49
75
 
50
- The signed PDF is delivered to your callback as a `signatureResponse`; download it by its
51
- `mediaId` using `@uveysservetoglu/kobil-chat`'s `getAttachmentFile`.
76
+ The signed PDF is delivered to your callback; download it by its `mediaId` using
77
+ `@uveysservetoglu/kobil-chat`'s `getAttachmentFile`.
52
78
 
53
79
  JavaScript usage is identical (`const { SignClient } = require("@uveysservetoglu/kobil-sign")`).
54
- Failures throw `KobilSignError` (extends `KobilError`).
80
+ Failures reject with `KobilSignError` (extends `KobilError`).
55
81
 
56
82
  ## License
57
83
 
package/dist/client.d.ts CHANGED
@@ -1,23 +1,28 @@
1
- import { KobilCredentials, KobilError, KobilServiceClient, TokenProvider } from "@uveysservetoglu/kobil-core";
1
+ import { ApiMode, KobilApiOptions, KobilCredentials, KobilError, KobilServiceClient, TokenProvider } from "@uveysservetoglu/kobil-core";
2
2
  import { InitiateSignatureInput, SignatureResult } from "./types";
3
- export interface SignClientOptions extends Partial<KobilCredentials> {
3
+ export interface SignClientOptions extends Partial<KobilCredentials>, KobilApiOptions {
4
4
  /**
5
- * Signature endpoint template up to the user segment, with {TENANT} and {USER_ID}.
5
+ * Legacy mode: signature endpoint template up to the user segment, with {TENANT} and {USER_ID}.
6
6
  * Derived from `MPOWER_BASE` when omitted — signing and chat share the same host.
7
7
  */
8
8
  signBaseUrl?: string;
9
- /** Tenant/realm name substituted for {TENANT}. Falls back to `MPOWER_TENANT`. */
9
+ /** Legacy mode: tenant/realm name substituted for {TENANT}. Falls back to `MPOWER_TENANT`. */
10
10
  tenantName?: string;
11
- /** serviceUuid sent with the request. Optional: defaults to clientId. */
11
+ /** Legacy mode: serviceUuid sent with the request. Optional: defaults to clientId. */
12
12
  serviceUuid?: string;
13
13
  /** Default callback URL for signature results; overridable per request. */
14
14
  defaultCallbackUrl?: string;
15
- /** Wire protocol version. Default: 3. */
15
+ /** Legacy mode: wire protocol version. Default: 3. */
16
16
  version?: number;
17
17
  tokenProvider?: TokenProvider;
18
18
  }
19
- /** Client for the KOBIL digital signature API. */
19
+ /**
20
+ * Client for KOBIL PDF signing: the MiniApp API's `/v1/messages/sendPdfSignature` (default) or the
21
+ * legacy mPower signature API.
22
+ */
20
23
  export declare class SignClient extends KobilServiceClient {
24
+ readonly apiMode: ApiMode;
25
+ private readonly apiBase;
21
26
  private readonly signBaseUrl;
22
27
  private readonly tenantName?;
23
28
  private readonly clientId;
@@ -26,6 +31,10 @@ export declare class SignClient extends KobilServiceClient {
26
31
  private readonly version;
27
32
  constructor(options?: SignClientOptions);
28
33
  protected makeError(message: string, statusCode?: number, responseBody?: string, cause?: unknown): KobilError;
34
+ /**
35
+ * Asks the user to sign a PDF. The signed document is delivered to the callback; download it by its
36
+ * `mediaId` with `@uveysservetoglu/kobil-chat`'s `getAttachmentFile`.
37
+ */
29
38
  initiatePdfSignature(input: InitiateSignatureInput, signal?: AbortSignal): Promise<SignatureResult>;
30
39
  private signatureUrl;
31
40
  private serviceUuid;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,aAAa,EAGd,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MA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perty(exports, "__esModule", { value: true });
3
3
  exports.SignClient = void 0;
4
4
  const kobil_core_1 = require("@uveysservetoglu/kobil-core");
5
5
  const error_1 = require("./error");
6
- /** Client for the KOBIL digital signature API. */
6
+ const position_1 = require("./position");
7
+ /**
8
+ * Client for KOBIL PDF signing: the MiniApp API's `/v1/messages/sendPdfSignature` (default) or the
9
+ * legacy mPower signature API.
10
+ */
7
11
  class SignClient extends kobil_core_1.KobilServiceClient {
12
+ apiMode;
13
+ apiBase;
8
14
  signBaseUrl;
9
15
  tenantName;
10
16
  clientId;
@@ -12,6 +18,7 @@ class SignClient extends kobil_core_1.KobilServiceClient {
12
18
  defaultCallbackUrl;
13
19
  version;
14
20
  constructor(options = {}) {
21
+ const apiMode = (0, kobil_core_1.resolveApiMode)(options.apiMode);
15
22
  const credentials = (0, kobil_core_1.credentialsFromEnv)({
16
23
  tokenEndpoint: options.tokenEndpoint,
17
24
  clientId: options.clientId,
@@ -19,12 +26,20 @@ class SignClient extends kobil_core_1.KobilServiceClient {
19
26
  tokenAuthMode: options.tokenAuthMode,
20
27
  defaultTokenTtlSeconds: options.defaultTokenTtlSeconds,
21
28
  tokenExpirySkewSeconds: options.tokenExpirySkewSeconds,
22
- });
29
+ }, { apiMode, apiBaseUrl: options.apiBaseUrl, realm: options.realm });
23
30
  super(options.tokenProvider ?? new kobil_core_1.DefaultTokenProvider(credentials));
24
- const signBaseUrl = options.signBaseUrl || (0, kobil_core_1.mpowerUserEndpoint)(process.env.MPOWER_BASE);
25
- if (!signBaseUrl)
26
- throw new kobil_core_1.KobilError("No signature endpoint: set MPOWER_BASE (or pass signBaseUrl).");
27
- this.signBaseUrl = signBaseUrl;
31
+ this.apiMode = apiMode;
32
+ if (apiMode === "legacy") {
33
+ const signBaseUrl = options.signBaseUrl || (0, kobil_core_1.mpowerUserEndpoint)(process.env.MPOWER_BASE);
34
+ if (!signBaseUrl)
35
+ throw new kobil_core_1.KobilError("No signature endpoint: set MPOWER_BASE (or pass signBaseUrl).");
36
+ this.signBaseUrl = signBaseUrl;
37
+ this.apiBase = "";
38
+ }
39
+ else {
40
+ this.signBaseUrl = "";
41
+ this.apiBase = (0, kobil_core_1.miniappApiBase)(options.apiBaseUrl);
42
+ }
28
43
  this.tenantName = options.tenantName ?? process.env.MPOWER_TENANT;
29
44
  this.clientId = credentials.clientId;
30
45
  this.serviceUuidOption = options.serviceUuid;
@@ -34,12 +49,45 @@ class SignClient extends kobil_core_1.KobilServiceClient {
34
49
  makeError(message, statusCode, responseBody, cause) {
35
50
  return new error_1.KobilSignError(message, { statusCode, responseBody, cause });
36
51
  }
37
- initiatePdfSignature(input, signal) {
52
+ /**
53
+ * Asks the user to sign a PDF. The signed document is delivered to the callback; download it by its
54
+ * `mediaId` with `@uveysservetoglu/kobil-chat`'s `getAttachmentFile`.
55
+ */
56
+ async initiatePdfSignature(input, signal) {
38
57
  if (!input.userId)
39
58
  throw new error_1.KobilSignError("userId cannot be empty.");
40
59
  if (!input.file || input.file.length === 0)
41
60
  throw new error_1.KobilSignError("file (PDF) cannot be empty.");
42
- const p = input.position;
61
+ const fields = signatureFields(input);
62
+ const callbackUrl = input.callbackUrl ?? this.defaultCallbackUrl;
63
+ if (this.apiMode === "miniapp") {
64
+ if (!input.messageText)
65
+ throw new error_1.KobilSignError("messageText is required in miniapp mode.");
66
+ if (fields.length > 20)
67
+ throw new error_1.KobilSignError(`The MiniApp API takes at most 20 signatures, got ${fields.length}.`);
68
+ const message = prune({
69
+ userId: input.userId,
70
+ text: input.messageText,
71
+ signature: fields.map((f) => ({
72
+ signeeUserId: f.signeeUserId ?? input.userId,
73
+ position: (0, position_1.toSignatureArea)(f.position),
74
+ })),
75
+ callbackUrl,
76
+ push: input.push,
77
+ });
78
+ return this.sendMultipart("POST", `${this.apiBase}/v1/messages/sendPdfSignature`, [
79
+ { name: "file", value: input.file, fileName: input.fileName ?? "document.pdf", contentType: "application/pdf" },
80
+ { name: "message", value: JSON.stringify(message), contentType: "application/json" },
81
+ ], signal);
82
+ }
83
+ if (fields.length !== 1) {
84
+ throw new error_1.KobilSignError("Legacy mode takes exactly one signature field: pass position (or one signature).");
85
+ }
86
+ const field = fields[0];
87
+ if (field.signeeUserId !== undefined && field.signeeUserId !== input.userId) {
88
+ throw new error_1.KobilSignError("Legacy mode cannot name a different signee: the recipient (userId) signs.");
89
+ }
90
+ const p = (0, position_1.toSignaturePosition)(field.position);
43
91
  const signatureData = {
44
92
  version: this.version,
45
93
  pageNumber: p.pageNumber ?? 1,
@@ -49,7 +97,7 @@ class SignClient extends kobil_core_1.KobilServiceClient {
49
97
  topRightYCoordinate: p.topRightY,
50
98
  serviceUuid: this.serviceUuid(),
51
99
  messageText: input.messageText,
52
- callbackUrl: input.callbackUrl ?? this.defaultCallbackUrl,
100
+ callbackUrl,
53
101
  };
54
102
  const form = new FormData();
55
103
  form.append("signatureFile", new Blob([input.file], { type: "application/pdf" }), input.fileName ?? "document.pdf");
@@ -65,6 +113,17 @@ class SignClient extends kobil_core_1.KobilServiceClient {
65
113
  }
66
114
  }
67
115
  exports.SignClient = SignClient;
116
+ /** The fields to sign: `signatures` if given, else the single `position`. */
117
+ function signatureFields(input) {
118
+ if (input.signatures && input.signatures.length > 0) {
119
+ if (input.position)
120
+ throw new error_1.KobilSignError("Pass either position or signatures, not both.");
121
+ return input.signatures;
122
+ }
123
+ if (!input.position)
124
+ throw new error_1.KobilSignError("A signature position is required: pass position (or signatures).");
125
+ return [{ position: input.position }];
126
+ }
68
127
  function replaceTokens(template, tokens) {
69
128
  let result = template;
70
129
  for (const [token, value] of Object.entries(tokens)) {
@@ -72,4 +131,13 @@ function replaceTokens(template, tokens) {
72
131
  }
73
132
  return result;
74
133
  }
134
+ /** Removes undefined/null properties so optional fields are omitted from the JSON body. */
135
+ function prune(obj) {
136
+ const out = {};
137
+ for (const [key, value] of Object.entries(obj)) {
138
+ if (value !== undefined && value !== null)
139
+ out[key] = value;
140
+ }
141
+ return out;
142
+ }
75
143
  //# sourceMappingURL=client.js.map
@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AAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,IAAI,KAAK,CAAC,QAAQ;YAAE,MAAM,IAAI,sBAAc,CAAC,+CAA+C,CAAC,CAAC;QAC9F,OAAO,KAAK,CAAC,UAAU,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,MAAM,IAAI,sBAAc,CAAC,kEAAkE,CAAC,CAAC;IAClH,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB,EAAE,MAA0C;IACjF,IAAI,MAAM,GAAG,QAAQ,CAAC;IACtB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2FAA2F;AAC3F,SAAS,KAAK,CAAC,GAA4B;IACzC,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { SignClient } from "./client";
2
2
  export type { SignClientOptions } from "./client";
3
3
  export { KobilSignError } from "./error";
4
- export type { InitiateSignatureInput, SignaturePosition, SignatureResult } from "./types";
4
+ export { toSignatureArea, toSignaturePosition } from "./position";
5
+ export type { InitiateSignatureInput, SignatureArea, SignatureField, SignatureFileMetadata, SignaturePosition, SignatureResult, } from "./types";
6
+ export type { PushContent, PushResponse } from "@uveysservetoglu/kobil-core";
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KobilSignError = exports.SignClient = void 0;
3
+ exports.toSignaturePosition = exports.toSignatureArea = exports.KobilSignError = exports.SignClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "SignClient", { enumerable: true, get: function () { return client_1.SignClient; } });
6
6
  var error_1 = require("./error");
7
7
  Object.defineProperty(exports, "KobilSignError", { enumerable: true, get: function () { return error_1.KobilSignError; } });
8
+ var position_1 = require("./position");
9
+ Object.defineProperty(exports, "toSignatureArea", { enumerable: true, get: function () { return position_1.toSignatureArea; } });
10
+ Object.defineProperty(exports, "toSignaturePosition", { enumerable: true, get: function () { return position_1.toSignaturePosition; } });
8
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AAEnB,iCAAyC;AAAhC,uGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AAEnB,iCAAyC;AAAhC,uGAAA,cAAc,OAAA;AACvB,uCAAkE;AAAzD,2GAAA,eAAe,OAAA;AAAE,+GAAA,mBAAmB,OAAA"}
@@ -0,0 +1,17 @@
1
+ import { SignatureArea, SignaturePosition } from "./types";
2
+ /**
3
+ * Conversions between the two APIs' signature rectangles. Both describe the same box relative to the
4
+ * page, so nothing about the PDF itself is needed:
5
+ *
6
+ * - legacy: integer percentages, origin bottom-left — `bottomLeftX/Y`, `topRightX/Y`
7
+ * - miniapp: fractions, origin top-left — `left`, `top`, `width`, `height`
8
+ */
9
+ export declare function isSignatureArea(position: SignaturePosition | SignatureArea): position is SignatureArea;
10
+ /** As a MiniApp API area. Areas pass through untouched. */
11
+ export declare function toSignatureArea(position: SignaturePosition | SignatureArea): SignatureArea;
12
+ /**
13
+ * As a legacy rectangle. Rounded to whole percentages: the legacy platform parses the coordinates as
14
+ * integers and rejects anything else.
15
+ */
16
+ export declare function toSignaturePosition(position: SignaturePosition | SignatureArea): SignaturePosition;
17
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,aAAa,GAAG,QAAQ,IAAI,aAAa,CAEtG;AAED,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,aAAa,GAAG,aAAa,CAS1F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,CASlG"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSignatureArea = isSignatureArea;
4
+ exports.toSignatureArea = toSignatureArea;
5
+ exports.toSignaturePosition = toSignaturePosition;
6
+ /**
7
+ * Conversions between the two APIs' signature rectangles. Both describe the same box relative to the
8
+ * page, so nothing about the PDF itself is needed:
9
+ *
10
+ * - legacy: integer percentages, origin bottom-left — `bottomLeftX/Y`, `topRightX/Y`
11
+ * - miniapp: fractions, origin top-left — `left`, `top`, `width`, `height`
12
+ */
13
+ function isSignatureArea(position) {
14
+ return "left" in position;
15
+ }
16
+ /** As a MiniApp API area. Areas pass through untouched. */
17
+ function toSignatureArea(position) {
18
+ if (isSignatureArea(position))
19
+ return position;
20
+ return {
21
+ page: position.pageNumber ?? 1,
22
+ left: fraction(position.bottomLeftX),
23
+ top: fraction(100 - position.topRightY),
24
+ width: fraction(position.topRightX - position.bottomLeftX),
25
+ height: fraction(position.topRightY - position.bottomLeftY),
26
+ };
27
+ }
28
+ /**
29
+ * As a legacy rectangle. Rounded to whole percentages: the legacy platform parses the coordinates as
30
+ * integers and rejects anything else.
31
+ */
32
+ function toSignaturePosition(position) {
33
+ if (!isSignatureArea(position))
34
+ return position;
35
+ return {
36
+ pageNumber: position.page,
37
+ bottomLeftX: Math.round(position.left * 100),
38
+ bottomLeftY: Math.round((1 - position.top - position.height) * 100),
39
+ topRightX: Math.round((position.left + position.width) * 100),
40
+ topRightY: Math.round((1 - position.top) * 100),
41
+ };
42
+ }
43
+ /** Percent → fraction, without the float noise (`0.59` rather than `0.5900000000000001`). */
44
+ function fraction(percent) {
45
+ return Math.round(percent * 1e4) / 1e6;
46
+ }
47
+ //# sourceMappingURL=position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.js","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":";;AAUA,0CAEC;AAGD,0CASC;AAMD,kDASC;AArCD;;;;;;GAMG;AAEH,SAAgB,eAAe,CAAC,QAA2C;IACzE,OAAO,MAAM,IAAI,QAAQ,CAAC;AAC5B,CAAC;AAED,2DAA2D;AAC3D,SAAgB,eAAe,CAAC,QAA2C;IACzE,IAAI,eAAe,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC/C,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,UAAU,IAAI,CAAC;QAC9B,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;QACpC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC;QACvC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC;QAC1D,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,QAA2C;IAC7E,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAChD,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,IAAI;QACzB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;QAC5C,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;QACnE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;QAC7D,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;KAChD,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACzC,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- /** Rectangle (in PDF points) where the signature is placed on a page. */
1
+ import type { PushContent, PushResponse } from "@uveysservetoglu/kobil-core";
2
+ /**
3
+ * Signature rectangle in the legacy API's coordinates: **integer percentages (0–100) of the page,
4
+ * origin bottom-left**. Accepted in both modes — miniapp mode converts it to a {@link SignatureArea}.
5
+ */
2
6
  export interface SignaturePosition {
3
7
  /** 1-based page number. Default: 1. */
4
8
  pageNumber?: number;
@@ -7,21 +11,63 @@ export interface SignaturePosition {
7
11
  topRightX: number;
8
12
  topRightY: number;
9
13
  }
14
+ /**
15
+ * Signature rectangle in the MiniApp API's coordinates: **fractions (0.0–1.0) of the page, origin
16
+ * top-left** (x to the right, y down). Accepted in both modes — legacy mode converts it to rounded
17
+ * percentages.
18
+ */
19
+ export interface SignatureArea {
20
+ /** 1-based page number. */
21
+ page: number;
22
+ left: number;
23
+ top: number;
24
+ width: number;
25
+ height: number;
26
+ }
27
+ /** One signature field and who signs it. */
28
+ export interface SignatureField {
29
+ /** The user who signs this field. Default: the request's `userId`. */
30
+ signeeUserId?: string;
31
+ position: SignaturePosition | SignatureArea;
32
+ }
10
33
  export interface InitiateSignatureInput {
34
+ /** Recipient of the signature request. */
11
35
  userId: string;
12
- /** Raw PDF bytes to be signed. */
36
+ /** Raw PDF bytes to be signed. Max 10 MB in miniapp mode. */
13
37
  file: Uint8Array;
14
38
  /** File name for the upload part. Default: "document.pdf". */
15
39
  fileName?: string;
16
- /** Prompt shown to the signer. */
40
+ /** Prompt shown to the signer. Required in miniapp mode. */
17
41
  messageText?: string;
18
- /** Callback URL for the signature result. Falls back to the configured default. */
42
+ /**
43
+ * Where the signed result is delivered. Falls back to the configured default; in miniapp mode, omit
44
+ * both to use the MiniApp's global callback.
45
+ */
19
46
  callbackUrl?: string;
20
- position: SignaturePosition;
47
+ /** The single field `userId` signs. Give this or `signatures`. */
48
+ position?: SignaturePosition | SignatureArea;
49
+ /** Several fields and/or signers (1–20). Miniapp mode only; legacy mode takes exactly one, signed by `userId`. */
50
+ signatures?: SignatureField[];
51
+ /** Miniapp mode: push notification bundled with the request. Ignored in legacy mode. */
52
+ push?: PushContent;
53
+ }
54
+ /** File details the MiniApp API returns for the uploaded PDF. */
55
+ export interface SignatureFileMetadata {
56
+ mediaId: string;
57
+ fileName: string;
58
+ contentType: string;
59
+ fileSize: number;
21
60
  }
22
61
  export interface SignatureResult {
23
62
  messageId?: string;
63
+ /** Legacy mode. */
24
64
  instanceId?: string;
65
+ /** Miniapp mode: when the request was created (ISO 8601). */
66
+ createdAt?: string;
67
+ /** Miniapp mode: the uploaded PDF. */
68
+ file?: SignatureFileMetadata;
69
+ /** Miniapp mode: outcome of the bundled push, when one was sent. */
70
+ push?: PushResponse;
25
71
  [key: string]: unknown;
26
72
  }
27
73
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAA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,sBAAsB;IACrC,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,IAAI,EAAE,UAAU,CAAC;IACjB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;IAC7C,kHAAkH;IAClH,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,wFAAwF;IACxF,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,oEAAoE;IACpE,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uveysservetoglu/kobil-sign",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "KOBIL digital signature client for Node.js: initiate PDF signatures with automatic OAuth token management.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "url": "https://github.com/uveysservetoglu/kobil-sdks"
20
20
  },
21
21
  "dependencies": {
22
- "@uveysservetoglu/kobil-core": "^2.0.0"
22
+ "@uveysservetoglu/kobil-core": "^3.0.0"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsc -b"