@capsara/sdk 1.0.5 → 2.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.
Files changed (129) hide show
  1. package/README.md +110 -28
  2. package/dist/builder/capsa-builder.d.ts +19 -11
  3. package/dist/builder/capsa-builder.d.ts.map +1 -1
  4. package/dist/builder/capsa-builder.js +149 -70
  5. package/dist/builder/capsa-builder.js.map +1 -1
  6. package/dist/client/capsara-client.d.ts +21 -26
  7. package/dist/client/capsara-client.d.ts.map +1 -1
  8. package/dist/client/capsara-client.js +86 -55
  9. package/dist/client/capsara-client.js.map +1 -1
  10. package/dist/errors/account-error.d.ts +5 -70
  11. package/dist/errors/account-error.d.ts.map +1 -1
  12. package/dist/errors/account-error.js +8 -146
  13. package/dist/errors/account-error.js.map +1 -1
  14. package/dist/errors/audit-error.d.ts +4 -28
  15. package/dist/errors/audit-error.d.ts.map +1 -1
  16. package/dist/errors/audit-error.js +9 -82
  17. package/dist/errors/audit-error.js.map +1 -1
  18. package/dist/errors/auth-error.d.ts +4 -35
  19. package/dist/errors/auth-error.d.ts.map +1 -1
  20. package/dist/errors/auth-error.js +6 -77
  21. package/dist/errors/auth-error.js.map +1 -1
  22. package/dist/errors/capsa-error.d.ts +5 -59
  23. package/dist/errors/capsa-error.d.ts.map +1 -1
  24. package/dist/errors/capsa-error.js +9 -156
  25. package/dist/errors/capsa-error.js.map +1 -1
  26. package/dist/errors/capsara-error.d.ts +24 -24
  27. package/dist/errors/capsara-error.d.ts.map +1 -1
  28. package/dist/errors/capsara-error.js +141 -34
  29. package/dist/errors/capsara-error.js.map +1 -1
  30. package/dist/errors/index.d.ts +1 -1
  31. package/dist/errors/index.d.ts.map +1 -1
  32. package/dist/index.d.ts +8 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/capsa-cache.d.ts +0 -1
  37. package/dist/internal/capsa-cache.d.ts.map +1 -1
  38. package/dist/internal/capsa-cache.js +7 -5
  39. package/dist/internal/capsa-cache.js.map +1 -1
  40. package/dist/internal/config/http-client.d.ts.map +1 -1
  41. package/dist/internal/config/http-client.js +48 -21
  42. package/dist/internal/config/http-client.js.map +1 -1
  43. package/dist/internal/config/retry-interceptor.d.ts +18 -1
  44. package/dist/internal/config/retry-interceptor.d.ts.map +1 -1
  45. package/dist/internal/config/retry-interceptor.js +104 -79
  46. package/dist/internal/config/retry-interceptor.js.map +1 -1
  47. package/dist/internal/config/token-refresh.d.ts +12 -0
  48. package/dist/internal/config/token-refresh.d.ts.map +1 -0
  49. package/dist/internal/config/token-refresh.js +43 -0
  50. package/dist/internal/config/token-refresh.js.map +1 -0
  51. package/dist/internal/crypto/compression.js +1 -1
  52. package/dist/internal/crypto/compression.js.map +1 -1
  53. package/dist/internal/crypto/key-generator.d.ts +3 -6
  54. package/dist/internal/crypto/key-generator.d.ts.map +1 -1
  55. package/dist/internal/crypto/key-generator.js +26 -27
  56. package/dist/internal/crypto/key-generator.js.map +1 -1
  57. package/dist/internal/crypto/primitives.d.ts +1 -2
  58. package/dist/internal/crypto/primitives.d.ts.map +1 -1
  59. package/dist/internal/crypto/primitives.js +7 -9
  60. package/dist/internal/crypto/primitives.js.map +1 -1
  61. package/dist/internal/crypto/signatures.d.ts +3 -1
  62. package/dist/internal/crypto/signatures.d.ts.map +1 -1
  63. package/dist/internal/crypto/signatures.js +14 -6
  64. package/dist/internal/crypto/signatures.js.map +1 -1
  65. package/dist/internal/decryptor/capsa-decryptor.d.ts +8 -54
  66. package/dist/internal/decryptor/capsa-decryptor.d.ts.map +1 -1
  67. package/dist/internal/decryptor/capsa-decryptor.js +125 -150
  68. package/dist/internal/decryptor/capsa-decryptor.js.map +1 -1
  69. package/dist/internal/http-factory.d.ts +3 -19
  70. package/dist/internal/http-factory.d.ts.map +1 -1
  71. package/dist/internal/http-factory.js +3 -140
  72. package/dist/internal/http-factory.js.map +1 -1
  73. package/dist/internal/services/account-service.d.ts +11 -33
  74. package/dist/internal/services/account-service.d.ts.map +1 -1
  75. package/dist/internal/services/account-service.js +38 -53
  76. package/dist/internal/services/account-service.js.map +1 -1
  77. package/dist/internal/services/audit-service.d.ts.map +1 -1
  78. package/dist/internal/services/audit-service.js +17 -1
  79. package/dist/internal/services/audit-service.js.map +1 -1
  80. package/dist/internal/services/auth-service.d.ts +3 -0
  81. package/dist/internal/services/auth-service.d.ts.map +1 -1
  82. package/dist/internal/services/auth-service.js +68 -17
  83. package/dist/internal/services/auth-service.js.map +1 -1
  84. package/dist/internal/services/capsa-service.d.ts +2 -26
  85. package/dist/internal/services/capsa-service.d.ts.map +1 -1
  86. package/dist/internal/services/capsa-service.js +8 -34
  87. package/dist/internal/services/capsa-service.js.map +1 -1
  88. package/dist/internal/services/download-service.d.ts +13 -27
  89. package/dist/internal/services/download-service.d.ts.map +1 -1
  90. package/dist/internal/services/download-service.js +23 -57
  91. package/dist/internal/services/download-service.js.map +1 -1
  92. package/dist/internal/services/key-service.d.ts +4 -14
  93. package/dist/internal/services/key-service.d.ts.map +1 -1
  94. package/dist/internal/services/key-service.js +35 -21
  95. package/dist/internal/services/key-service.js.map +1 -1
  96. package/dist/internal/services/limits-service.d.ts +2 -16
  97. package/dist/internal/services/limits-service.d.ts.map +1 -1
  98. package/dist/internal/services/limits-service.js +18 -28
  99. package/dist/internal/services/limits-service.js.map +1 -1
  100. package/dist/internal/services/upload-service.d.ts +33 -26
  101. package/dist/internal/services/upload-service.d.ts.map +1 -1
  102. package/dist/internal/services/upload-service.js +309 -133
  103. package/dist/internal/services/upload-service.js.map +1 -1
  104. package/dist/internal/types.d.ts +0 -1
  105. package/dist/internal/types.d.ts.map +1 -1
  106. package/dist/internal/utils/filename-check.d.ts +11 -0
  107. package/dist/internal/utils/filename-check.d.ts.map +1 -0
  108. package/dist/internal/utils/filename-check.js +28 -0
  109. package/dist/internal/utils/filename-check.js.map +1 -0
  110. package/dist/internal/utils/safe-filename.d.ts +31 -0
  111. package/dist/internal/utils/safe-filename.d.ts.map +1 -0
  112. package/dist/internal/utils/safe-filename.js +126 -0
  113. package/dist/internal/utils/safe-filename.js.map +1 -0
  114. package/dist/internal/version.d.ts +2 -16
  115. package/dist/internal/version.d.ts.map +1 -1
  116. package/dist/internal/version.js +4 -16
  117. package/dist/internal/version.js.map +1 -1
  118. package/dist/types/index.d.ts +26 -10
  119. package/dist/types/index.d.ts.map +1 -1
  120. package/dist/types/index.js.map +1 -1
  121. package/package.json +13 -11
  122. package/dist/internal/index.d.ts +0 -5
  123. package/dist/internal/index.d.ts.map +0 -1
  124. package/dist/internal/index.js +0 -5
  125. package/dist/internal/index.js.map +0 -1
  126. package/dist/internal/retry-executor.d.ts +0 -74
  127. package/dist/internal/retry-executor.d.ts.map +0 -1
  128. package/dist/internal/retry-executor.js +0 -204
  129. package/dist/internal/retry-executor.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ /** File name check for files added to a capsa. */
2
+ import { isControl } from './safe-filename.js';
3
+ /**
4
+ * Describe why a file name cannot be sent, or return undefined if it can.
5
+ *
6
+ * A sent name must be a plain file name: no "/" or "\", no control characters,
7
+ * not empty or only spaces, and not "." or "..". The message does not repeat
8
+ * the name.
9
+ * @param name - The file name a sender supplied
10
+ */
11
+ export function filenameSendProblem(name) {
12
+ if (name.includes('/') || name.includes('\\')) {
13
+ return 'File name must not contain a path separator ("/" or "\\"). Pass the file name only.';
14
+ }
15
+ for (const ch of name) {
16
+ if (isControl(ch.codePointAt(0) ?? 0)) {
17
+ return 'File name must not contain control characters.';
18
+ }
19
+ }
20
+ if (name.replace(/ /g, '').length === 0) {
21
+ return 'File name must not be empty or only spaces.';
22
+ }
23
+ if (name === '.' || name === '..') {
24
+ return 'File name must not be "." or "..".';
25
+ }
26
+ return undefined;
27
+ }
28
+ //# sourceMappingURL=filename-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filename-check.js","sourceRoot":"","sources":["../../../src/internal/utils/filename-check.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,OAAO,qFAAqF,CAAC;IAC/F,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACtC,OAAO,gDAAgD,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,6CAA6C,CAAC;IACvD,CAAC;IACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClC,OAAO,oCAAoC,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Safe file names for received files.
3
+ *
4
+ * A received file's name is decrypted from what the sender supplied, so it is
5
+ * untrusted: it can hold path separators, control characters or names that
6
+ * Windows reserves. sanitizeFilename turns any name into a single path segment
7
+ * that is safe to join to a directory of the caller's choosing.
8
+ */
9
+ /** Whether a code point is a control character (U+0000 to U+001F, or U+007F). */
10
+ export declare function isControl(codePoint: number): boolean;
11
+ /**
12
+ * Turn an untrusted file name into a safe single path segment.
13
+ *
14
+ * Rules, applied in order:
15
+ * 1. Keep only the part after the last "/" or "\".
16
+ * 2. Remove control characters (U+0000 to U+001F and U+007F).
17
+ * 3. Replace the characters Windows does not allow (< > : " | ? *) with "_".
18
+ * 4. Trim leading and trailing spaces, and trailing dots.
19
+ * 5. Cap the name at 255 UTF-8 bytes, keeping an extension of up to 32 bytes
20
+ * and never splitting a character.
21
+ * 6. Use "file" for an empty result, and prefix "_" to ".", "..", and Windows
22
+ * reserved device names (CON, PRN, AUX, NUL, COM1 to COM9, LPT1 to LPT9, in
23
+ * any case, with or without an extension).
24
+ *
25
+ * The result is never empty, holds no path separator, and is at most 255 UTF-8
26
+ * bytes. It is a name only: join it to a directory you chose.
27
+ * @param name - The untrusted file name
28
+ * @returns A safe file name
29
+ */
30
+ export declare function sanitizeFilename(name: string): string;
31
+ //# sourceMappingURL=safe-filename.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-filename.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/safe-filename.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD;AAmED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAerD"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Safe file names for received files.
3
+ *
4
+ * A received file's name is decrypted from what the sender supplied, so it is
5
+ * untrusted: it can hold path separators, control characters or names that
6
+ * Windows reserves. sanitizeFilename turns any name into a single path segment
7
+ * that is safe to join to a directory of the caller's choosing.
8
+ */
9
+ /** Maximum UTF-8 bytes of a safe file name. */
10
+ const MAX_FILENAME_BYTES = 255;
11
+ /** Longest extension, in UTF-8 bytes including the dot, kept when a name is cut. */
12
+ const MAX_EXTENSION_BYTES = 32;
13
+ const FALLBACK_FILENAME = 'file';
14
+ const WINDOWS_INVALID = new Set(['<', '>', ':', '"', '|', '?', '*']);
15
+ const RESERVED_NAMES = new Set([
16
+ 'CON', 'PRN', 'AUX', 'NUL',
17
+ 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9',
18
+ 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9',
19
+ ]);
20
+ /** Whether a code point is a control character (U+0000 to U+001F, or U+007F). */
21
+ export function isControl(codePoint) {
22
+ return codePoint <= 0x1f || codePoint === 0x7f;
23
+ }
24
+ function utf8Length(codePoint) {
25
+ if (codePoint < 0x80)
26
+ return 1;
27
+ if (codePoint < 0x800)
28
+ return 2;
29
+ if (codePoint < 0x10000)
30
+ return 3;
31
+ return 4;
32
+ }
33
+ function utf8ByteLength(value) {
34
+ let total = 0;
35
+ for (const ch of value) {
36
+ total += utf8Length(ch.codePointAt(0) ?? 0);
37
+ }
38
+ return total;
39
+ }
40
+ function trimStartSpaces(value) {
41
+ let start = 0;
42
+ while (start < value.length && value[start] === ' ')
43
+ start++;
44
+ return value.slice(start);
45
+ }
46
+ function trimEndSpacesAndDots(value) {
47
+ let end = value.length;
48
+ while (end > 0 && (value[end - 1] === ' ' || value[end - 1] === '.'))
49
+ end--;
50
+ return value.slice(0, end);
51
+ }
52
+ function isReserved(name) {
53
+ const dot = name.indexOf('.');
54
+ let stem = dot === -1 ? name : name.slice(0, dot);
55
+ let end = stem.length;
56
+ while (end > 0 && stem[end - 1] === ' ')
57
+ end--;
58
+ stem = stem.slice(0, end);
59
+ return RESERVED_NAMES.has(stem.replace(/[a-z]/g, (c) => c.toUpperCase()));
60
+ }
61
+ /** Longest prefix of whole code points whose UTF-8 form fits in maxBytes. */
62
+ function truncateUtf8(value, maxBytes) {
63
+ let used = 0;
64
+ let out = '';
65
+ for (const ch of value) {
66
+ const size = utf8Length(ch.codePointAt(0) ?? 0);
67
+ if (used + size > maxBytes)
68
+ break;
69
+ used += size;
70
+ out += ch;
71
+ }
72
+ return out;
73
+ }
74
+ function capLength(name, maxBytes) {
75
+ if (utf8ByteLength(name) <= maxBytes)
76
+ return name;
77
+ let stem = name;
78
+ let extension = '';
79
+ const dot = name.lastIndexOf('.');
80
+ if (dot > 0) {
81
+ const candidate = name.slice(dot);
82
+ if (utf8ByteLength(candidate) <= MAX_EXTENSION_BYTES) {
83
+ extension = candidate;
84
+ stem = name.slice(0, dot);
85
+ }
86
+ }
87
+ stem = trimEndSpacesAndDots(truncateUtf8(stem, maxBytes - utf8ByteLength(extension)));
88
+ return stem + extension;
89
+ }
90
+ /**
91
+ * Turn an untrusted file name into a safe single path segment.
92
+ *
93
+ * Rules, applied in order:
94
+ * 1. Keep only the part after the last "/" or "\".
95
+ * 2. Remove control characters (U+0000 to U+001F and U+007F).
96
+ * 3. Replace the characters Windows does not allow (< > : " | ? *) with "_".
97
+ * 4. Trim leading and trailing spaces, and trailing dots.
98
+ * 5. Cap the name at 255 UTF-8 bytes, keeping an extension of up to 32 bytes
99
+ * and never splitting a character.
100
+ * 6. Use "file" for an empty result, and prefix "_" to ".", "..", and Windows
101
+ * reserved device names (CON, PRN, AUX, NUL, COM1 to COM9, LPT1 to LPT9, in
102
+ * any case, with or without an extension).
103
+ *
104
+ * The result is never empty, holds no path separator, and is at most 255 UTF-8
105
+ * bytes. It is a name only: join it to a directory you chose.
106
+ * @param name - The untrusted file name
107
+ * @returns A safe file name
108
+ */
109
+ export function sanitizeFilename(name) {
110
+ const lastSeparator = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\'));
111
+ let result = '';
112
+ for (const ch of name.slice(lastSeparator + 1)) {
113
+ if (isControl(ch.codePointAt(0) ?? 0))
114
+ continue;
115
+ result += WINDOWS_INVALID.has(ch) ? '_' : ch;
116
+ }
117
+ result = trimEndSpacesAndDots(trimStartSpaces(result));
118
+ result = capLength(result, MAX_FILENAME_BYTES);
119
+ if (result.length === 0)
120
+ return FALLBACK_FILENAME;
121
+ if (result === '.' || result === '..' || isReserved(result)) {
122
+ return `_${capLength(result, MAX_FILENAME_BYTES - 1)}`;
123
+ }
124
+ return result;
125
+ }
126
+ //# sourceMappingURL=safe-filename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-filename.js","sourceRoot":"","sources":["../../../src/internal/utils/safe-filename.ts"],"names":[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IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9E,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/C,IAAI,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAAE,SAAS;QAChD,MAAM,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC;IACD,MAAM,GAAG,oBAAoB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAE/C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAClD,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,CAAC,CAAC,EAAE,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,20 +1,6 @@
1
- /**
2
- * SDK version information
3
- * @file capsara.sdk/typescript/src/internal/version.ts
4
- *
5
- * Note: This version should be updated when package.json version changes.
6
- * Consider using a build step to sync these values automatically.
7
- */
8
- /** SDK version - must match package.json */
9
- export declare const SDK_VERSION = "1.0.4";
10
- /** SDK name for User-Agent header */
1
+ /** SDK version information, read from the package manifest. */
2
+ export declare const SDK_VERSION: string;
11
3
  export declare const SDK_NAME = "Capsara-SDK-typescript";
12
- /** Default User-Agent string */
13
4
  export declare const DEFAULT_USER_AGENT: string;
14
- /**
15
- * Build User-Agent string with optional custom suffix
16
- * @param customAgent - Optional custom agent string to append
17
- * @returns Complete User-Agent string
18
- */
19
5
  export declare function buildUserAgent(customAgent?: string): string;
20
6
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/internal/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4CAA4C;AAC5C,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,qCAAqC;AACrC,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AAEjD,gCAAgC;AAChC,eAAO,MAAM,kBAAkB,QAA4D,CAAC;AAE5F;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3D"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/internal/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAM/D,eAAO,MAAM,WAAW,EAAE,MAAgC,CAAC;AAE3D,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AAEjD,eAAO,MAAM,kBAAkB,QAA4D,CAAC;AAE5F,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3D"}
@@ -1,21 +1,9 @@
1
- /**
2
- * SDK version information
3
- * @file capsara.sdk/typescript/src/internal/version.ts
4
- *
5
- * Note: This version should be updated when package.json version changes.
6
- * Consider using a build step to sync these values automatically.
7
- */
8
- /** SDK version - must match package.json */
9
- export const SDK_VERSION = '1.0.4';
10
- /** SDK name for User-Agent header */
1
+ /** SDK version information, read from the package manifest. */
2
+ import { createRequire } from 'module';
3
+ const packageManifest = createRequire(import.meta.url)('../../package.json');
4
+ export const SDK_VERSION = packageManifest.version;
11
5
  export const SDK_NAME = 'Capsara-SDK-typescript';
12
- /** Default User-Agent string */
13
6
  export const DEFAULT_USER_AGENT = `${SDK_NAME}/${SDK_VERSION} (Node.js ${process.version})`;
14
- /**
15
- * Build User-Agent string with optional custom suffix
16
- * @param customAgent - Optional custom agent string to append
17
- * @returns Complete User-Agent string
18
- */
19
7
  export function buildUserAgent(customAgent) {
20
8
  if (customAgent) {
21
9
  return `${DEFAULT_USER_AGENT} ${customAgent}`;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/internal/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,qCAAqC;AACrC,MAAM,CAAC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAEjD,gCAAgC;AAChC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,QAAQ,IAAI,WAAW,aAAa,OAAO,CAAC,OAAO,GAAG,CAAC;AAE5F;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,WAAoB;IACjD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,GAAG,kBAAkB,IAAI,WAAW,EAAE,CAAC;IAChD,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/internal/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAwB,CAAC;AAEpG,MAAM,CAAC,MAAM,WAAW,GAAW,eAAe,CAAC,OAAO,CAAC;AAE3D,MAAM,CAAC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,QAAQ,IAAI,WAAW,aAAa,OAAO,CAAC,OAAO,GAAG,CAAC;AAE5F,MAAM,UAAU,cAAc,CAAC,WAAoB;IACjD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,GAAG,kBAAkB,IAAI,WAAW,EAAE,CAAC;IAChD,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -1,17 +1,18 @@
1
1
  export type { KeychainEntry, EncryptedFile, CapsaSignature, CapsaMetadata, } from '../internal/types.js';
2
2
  export interface PartyKey {
3
3
  id: string;
4
- email: string;
5
4
  publicKey: string;
6
5
  fingerprint: string;
7
6
  isDelegate?: boolean | string[];
8
7
  }
8
+ export type CapsaStatus = 'active' | 'expired' | 'soft_deleted' | (string & {});
9
9
  export interface Capsa {
10
10
  id: string;
11
11
  createdAt: string;
12
12
  updatedAt: string;
13
- status: 'active' | 'soft_deleted' | 'expired';
13
+ status?: CapsaStatus | null;
14
14
  creator: string;
15
+ creatorPublicKey?: string;
15
16
  signature: {
16
17
  algorithm: string;
17
18
  protected: string;
@@ -61,7 +62,7 @@ export interface RecipientConfig {
61
62
  actingFor?: string[];
62
63
  }
63
64
  export interface AuthCredentials {
64
- email: string;
65
+ partyId: string;
65
66
  password: string;
66
67
  }
67
68
  export interface AuthResponse {
@@ -80,18 +81,26 @@ export interface AuthResponse {
80
81
  export interface SystemLimits {
81
82
  maxFileSize: number;
82
83
  maxFilesPerCapsa: number;
84
+ /** Maximum bytes in a single capsa */
83
85
  maxTotalSize: number;
86
+ /** Maximum bytes in one upload request, which may batch several capsas */
87
+ maxRequestSize?: number;
88
+ /** Maximum total bytes of the JSON fields in one upload request */
89
+ maxRequestFieldBytes?: number;
90
+ /** Maximum number of files in one upload request, across all of its capsas */
91
+ maxFilesPerRequest?: number;
92
+ /** Maximum number of days into the future a capsa or file may expire */
93
+ maxExpirationDays?: number;
84
94
  }
85
95
  export type { GeneratedKeyPair } from '../internal/crypto/key-generator.js';
86
- export type { PublicKeyInfo, KeyHistoryEntry } from '../internal/services/account-service.js';
96
+ export type { PublicKeyInfo, KeyHistoryEntry, RotateKeyOptions } from '../internal/services/account-service.js';
87
97
  export type { BuiltCapsa, CapsaUploadData } from '../builder/capsa-builder.js';
88
98
  export interface CapsaListFilters {
89
- status?: 'active' | 'expired';
99
+ status?: 'active' | 'expired' | 'soft_deleted';
90
100
  createdBy?: string;
91
101
  startDate?: string;
92
102
  endDate?: string;
93
103
  expiringBefore?: string;
94
- hasLegalHold?: boolean;
95
104
  limit?: number;
96
105
  after?: string;
97
106
  before?: string;
@@ -105,7 +114,7 @@ export interface CapsaSummary {
105
114
  id: string;
106
115
  createdAt: string;
107
116
  creator: string;
108
- status: 'active' | 'soft_deleted' | 'expired';
117
+ status?: CapsaStatus | null;
109
118
  expiresAt?: string;
110
119
  }
111
120
  export interface CursorPagination {
@@ -114,15 +123,22 @@ export interface CursorPagination {
114
123
  nextCursor?: string;
115
124
  prevCursor?: string;
116
125
  }
126
+ /** Page-based pagination returned by the audit endpoint */
127
+ export interface OffsetPagination {
128
+ page: number | null;
129
+ limit: number | null;
130
+ total: number | null;
131
+ totalPages: number | null;
132
+ }
117
133
  export interface AuditEntry {
118
134
  timestamp: string;
119
135
  party: string;
120
136
  action: AuditAction;
121
137
  ipAddress?: string;
122
- deviceFingerprint?: string;
138
+ userAgent?: string;
123
139
  details?: Record<string, unknown>;
124
140
  }
125
- export type AuditAction = 'created' | 'accessed' | 'file_downloaded' | 'processed' | 'expired' | 'deleted' | 'log';
141
+ export type AuditAction = 'created' | 'accessed' | 'file_downloaded' | 'processed' | 'expired' | 'soft_deleted' | 'hard_deleted' | 'webhook.delivered' | 'webhook.failed' | 'log';
126
142
  export interface GetAuditEntriesFilters {
127
143
  action?: string;
128
144
  party?: string;
@@ -131,7 +147,7 @@ export interface GetAuditEntriesFilters {
131
147
  }
132
148
  export interface GetAuditEntriesResponse {
133
149
  auditEntries: AuditEntry[];
134
- pagination: CursorPagination;
150
+ pagination: OffsetPagination;
135
151
  }
136
152
  export interface CreateAuditEntryRequest {
137
153
  action: 'log' | 'processed';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV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jC,CAAC;IAED,YAAY,CAAC,KAAgB,EAAE,QAAgB;QAC7C,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@capsara/sdk",
3
- "version": "1.0.5",
3
+ "version": "2.0.0",
4
4
  "description": "Capsara SDK for TypeScript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "clean": "rm -rf dist",
9
+ "clean": "rimraf dist",
10
10
  "build": "npm run clean && tsc",
11
11
  "dev": "tsc --watch",
12
12
  "test": "vitest",
13
13
  "test:coverage": "vitest --coverage",
14
14
  "lint": "eslint src/**/*.ts",
15
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
15
16
  "prepublishOnly": "npm run build"
16
17
  },
17
18
  "keywords": [
@@ -41,17 +42,18 @@
41
42
  "node": ">=20.0.0"
42
43
  },
43
44
  "dependencies": {
44
- "axios": "^1.15.0"
45
+ "axios": "^1.21.0"
45
46
  },
46
47
  "devDependencies": {
47
- "@eslint/js": "^9.39.1",
48
- "@types/node": "^20.17.10",
49
- "@typescript-eslint/eslint-plugin": "^8.18.2",
50
- "@typescript-eslint/parser": "^8.18.2",
51
- "@vitest/coverage-v8": "^2.1.8",
52
- "eslint": "^9.18.0",
53
- "typescript": "^5.9.0",
54
- "vitest": "^2.1.8"
48
+ "@eslint/js": "^10.0.1",
49
+ "@types/node": "^22.20.5",
50
+ "@typescript-eslint/eslint-plugin": "^8.72.1",
51
+ "@typescript-eslint/parser": "^8.72.1",
52
+ "@vitest/coverage-v8": "^5.0.5",
53
+ "eslint": "^10.14.0",
54
+ "rimraf": "^6.1.3",
55
+ "typescript": "~6.0.3",
56
+ "vitest": "^5.0.5"
55
57
  },
56
58
  "files": [
57
59
  "dist",
@@ -1,5 +0,0 @@
1
- /** Internal module exports. */
2
- export { createHttpClient, createAgentForProtocol, DEFAULT_TIMEOUT_CONFIG, type HttpClientOptions, type HttpTimeoutConfig, type RetryLogger, } from './http-factory.js';
3
- export { RetryExecutor, createRetryExecutor, type RetryConfig, type RawHttpOptions, type RawHttpResponse, } from './retry-executor.js';
4
- export { DecryptedCapsaCache, createCapsaCache, type CachedCapsa, type CachedFileMetadata, type CapsaCacheConfig, } from './capsa-cache.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC"}
@@ -1,5 +0,0 @@
1
- /** Internal module exports. */
2
- export { createHttpClient, createAgentForProtocol, DEFAULT_TIMEOUT_CONFIG, } from './http-factory.js';
3
- export { RetryExecutor, createRetryExecutor, } from './retry-executor.js';
4
- export { DecryptedCapsaCache, createCapsaCache, } from './capsa-cache.js';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GAIvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GAIjB,MAAM,kBAAkB,CAAC"}
@@ -1,74 +0,0 @@
1
- /**
2
- * Unified retry executor - eliminates retry logic duplication
3
- * @file capsara.sdk/typescript/src/internal/retry-executor.ts
4
- *
5
- * This module provides a unified retry mechanism that can be used for:
6
- * - Axios HTTP requests (via interceptor in http-factory)
7
- * - Raw HTTP/HTTPS requests (for multipart uploads)
8
- * - Generic async operations
9
- */
10
- import * as http from 'http';
11
- import { type HttpTimeoutConfig } from './http-factory.js';
12
- /**
13
- * Logger interface for retry operations
14
- */
15
- export interface RetryLogger {
16
- log: (message: string) => void;
17
- }
18
- /**
19
- * Retry configuration
20
- */
21
- export interface RetryConfig {
22
- maxRetries?: number;
23
- baseDelay?: number;
24
- maxDelay?: number;
25
- enableLogging?: boolean;
26
- logger?: RetryLogger;
27
- }
28
- /**
29
- * Options for raw HTTP requests
30
- */
31
- export interface RawHttpOptions {
32
- url: string;
33
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
34
- headers?: Record<string, string>;
35
- body?: Buffer | string;
36
- timeout?: number;
37
- timeoutConfig?: HttpTimeoutConfig;
38
- }
39
- /**
40
- * Response from raw HTTP request
41
- */
42
- export interface RawHttpResponse {
43
- statusCode: number;
44
- headers: http.IncomingHttpHeaders;
45
- body: Buffer;
46
- }
47
- /**
48
- * Unified retry executor for both axios and raw HTTP requests
49
- */
50
- export declare class RetryExecutor {
51
- private config;
52
- constructor(config?: RetryConfig);
53
- /**
54
- * Execute a generic async operation with retry
55
- */
56
- execute<T>(operation: () => Promise<T>, isRetryable?: (error: unknown) => boolean): Promise<T>;
57
- /**
58
- * Execute a raw HTTP request with retry (for multipart uploads)
59
- *
60
- * This replaces the duplicated retry logic in:
61
- * - CapsaraClient#sendCapsasWithRetry (121 lines)
62
- * - CapsaraClient#downloadFileWithRetry (54 lines)
63
- */
64
- executeRawHttp(options: RawHttpOptions): Promise<RawHttpResponse>;
65
- /**
66
- * Make a single raw HTTP request
67
- */
68
- private makeRawRequest;
69
- }
70
- /**
71
- * Create a retry executor with default or custom configuration
72
- */
73
- export declare function createRetryExecutor(config?: RetryConfig): RetryExecutor;
74
- //# sourceMappingURL=retry-executor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry-executor.d.ts","sourceRoot":"","sources":["../../src/internal/retry-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAA0B,KAAK,iBAAiB,EAA0B,MAAM,mBAAmB,CAAC;AAE3G;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AA4DD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MA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