@crittora/sdk-js 2.0.0 → 2.0.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.
- package/README.md +75 -5
- package/dist/client.d.ts +2 -1
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -1
- package/dist/crittora.d.ts +4 -0
- package/dist/crittora.js +12 -0
- package/dist/crittora.js.map +1 -1
- package/dist/resources/crypto.d.ts +2 -1
- package/dist/resources/crypto.js +23 -3
- package/dist/resources/crypto.js.map +1 -1
- package/dist/types.d.ts +16 -6
- package/docs/API.md +68 -4
- package/docs/ARCHITECTURE.md +12 -0
- package/docs/MIGRATION.md +40 -1
- package/docs/RELEASING.md +98 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Crittora JavaScript SDK
|
|
2
2
|
|
|
3
|
-
The Crittora JavaScript SDK
|
|
3
|
+
The Crittora JavaScript SDK is a typed secure-message client for the Crittora API.
|
|
4
|
+
|
|
5
|
+
It supports exactly two application workflows:
|
|
6
|
+
|
|
7
|
+
- confidentiality only: `encrypt()` -> `decrypt()`
|
|
8
|
+
- confidentiality plus authenticity: `signEncrypt()` -> `decryptVerify()`
|
|
4
9
|
|
|
5
10
|
This package now exposes a v2-style, instance-based client designed for predictable integration in production systems:
|
|
6
11
|
|
|
@@ -185,6 +190,36 @@ Operational guidance:
|
|
|
185
190
|
- Keep retry counts conservative unless the backend contract explicitly supports aggressive retries.
|
|
186
191
|
- Prefer a custom `userAgent` in services where request attribution matters.
|
|
187
192
|
|
|
193
|
+
## Supported Workflows
|
|
194
|
+
|
|
195
|
+
### Confidentiality only
|
|
196
|
+
|
|
197
|
+
Use `encrypt()` when the recipient only needs to recover the plaintext later:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const encrypted = await client.encrypt({
|
|
201
|
+
data: "hello",
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const decrypted = await client.decrypt({
|
|
205
|
+
encryptedData: encrypted.encryptedData,
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Confidentiality plus authenticity
|
|
210
|
+
|
|
211
|
+
Use `signEncrypt()` when the recipient must recover the plaintext and validate who signed it:
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
const envelope = await client.signEncrypt({
|
|
215
|
+
data: "hello",
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const verified = await client.decryptVerify({
|
|
219
|
+
encryptedData: envelope.encryptedData,
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
188
223
|
## Operations
|
|
189
224
|
|
|
190
225
|
### Encrypt
|
|
@@ -201,9 +236,28 @@ const result = await client.encrypt({
|
|
|
201
236
|
});
|
|
202
237
|
|
|
203
238
|
console.log(result.encryptedData);
|
|
204
|
-
console.log(result.transactionId);
|
|
205
239
|
```
|
|
206
240
|
|
|
241
|
+
`encrypt()` returns a single org-protected `encryptedData` envelope. The intended follow-up operation is `decrypt()`, which unwraps and decrypts that envelope through the API.
|
|
242
|
+
|
|
243
|
+
### Sign and encrypt
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
const result = await client.signEncrypt({
|
|
247
|
+
data: "hello",
|
|
248
|
+
permissions: [
|
|
249
|
+
{
|
|
250
|
+
partnerId: "partner-123",
|
|
251
|
+
actions: ["read", "write"],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
console.log(result.encryptedData);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`signEncrypt()` returns a single org-protected `encryptedData` envelope. The intended follow-up operation is `decryptVerify()`, which decrypts the envelope and validates the stored signature.
|
|
260
|
+
|
|
207
261
|
### Decrypt
|
|
208
262
|
|
|
209
263
|
```ts
|
|
@@ -214,6 +268,8 @@ const result = await client.decrypt({
|
|
|
214
268
|
console.log(result.decryptedData);
|
|
215
269
|
```
|
|
216
270
|
|
|
271
|
+
`decrypt()` is the intended follow-up to `encrypt()`. Pass it the exact `encryptedData` envelope returned by `encrypt()`, not the inner ciphertext payload.
|
|
272
|
+
|
|
217
273
|
### Decrypt and verify
|
|
218
274
|
|
|
219
275
|
```ts
|
|
@@ -223,8 +279,12 @@ const result = await client.decryptVerify({
|
|
|
223
279
|
|
|
224
280
|
console.log(result.decryptedData);
|
|
225
281
|
console.log(result.isValidSignature);
|
|
282
|
+
console.log(result.signedBy);
|
|
283
|
+
console.log(result.signedTimestamp);
|
|
226
284
|
```
|
|
227
285
|
|
|
286
|
+
`decryptVerify()` is the intended follow-up to `signEncrypt()`. Pass it the exact `encryptedData` envelope returned by `signEncrypt()`, not any inner payload.
|
|
287
|
+
|
|
228
288
|
Public request and response types:
|
|
229
289
|
|
|
230
290
|
```ts
|
|
@@ -240,7 +300,15 @@ type EncryptInput = {
|
|
|
240
300
|
|
|
241
301
|
type EncryptResult = {
|
|
242
302
|
encryptedData: string;
|
|
243
|
-
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
type SignEncryptInput = {
|
|
306
|
+
data: string;
|
|
307
|
+
permissions?: Permission[];
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
type SignEncryptResult = {
|
|
311
|
+
encryptedData: string;
|
|
244
312
|
};
|
|
245
313
|
|
|
246
314
|
type DecryptInput = {
|
|
@@ -250,13 +318,14 @@ type DecryptInput = {
|
|
|
250
318
|
|
|
251
319
|
type DecryptResult = {
|
|
252
320
|
decryptedData: string;
|
|
253
|
-
transactionId?: string;
|
|
254
321
|
};
|
|
255
322
|
|
|
256
323
|
type DecryptVerifyResult = {
|
|
257
324
|
decryptedData: string;
|
|
258
325
|
isValidSignature: boolean;
|
|
259
|
-
|
|
326
|
+
signedBy?: string;
|
|
327
|
+
signedTimestamp?: string;
|
|
328
|
+
repudiator?: string;
|
|
260
329
|
};
|
|
261
330
|
```
|
|
262
331
|
|
|
@@ -346,3 +415,4 @@ await client.withAuth({ type: "bearer", token: idToken }).encrypt({
|
|
|
346
415
|
- [API Reference](./docs/API.md)
|
|
347
416
|
- [Migration Guide](./docs/MIGRATION.md)
|
|
348
417
|
- [Architecture Notes](./docs/ARCHITECTURE.md)
|
|
418
|
+
- [Release Process](./docs/RELEASING.md)
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthProvider } from "./auth/types";
|
|
2
|
-
import { CrittoraClientOptions, DecryptInput, DecryptResult, DecryptVerifyInput, DecryptVerifyResult, EncryptInput, EncryptResult } from "./types";
|
|
2
|
+
import { CrittoraClientOptions, DecryptInput, DecryptResult, DecryptVerifyInput, DecryptVerifyResult, EncryptInput, EncryptResult, SignEncryptInput, SignEncryptResult } from "./types";
|
|
3
3
|
export declare class CrittoraClient {
|
|
4
4
|
private readonly options;
|
|
5
5
|
private readonly transport;
|
|
@@ -12,6 +12,7 @@ export declare class CrittoraClient {
|
|
|
12
12
|
token: string;
|
|
13
13
|
}): CrittoraClient;
|
|
14
14
|
encrypt(input: EncryptInput): Promise<EncryptResult>;
|
|
15
|
+
signEncrypt(input: SignEncryptInput): Promise<SignEncryptResult>;
|
|
15
16
|
decrypt(input: DecryptInput): Promise<DecryptResult>;
|
|
16
17
|
decryptVerify(input: DecryptVerifyInput): Promise<DecryptVerifyResult>;
|
|
17
18
|
private resolveAuthProvider;
|
package/dist/client.js
CHANGED
|
@@ -34,6 +34,9 @@ class CrittoraClient {
|
|
|
34
34
|
async encrypt(input) {
|
|
35
35
|
return this.cryptoResource.encrypt(input);
|
|
36
36
|
}
|
|
37
|
+
async signEncrypt(input) {
|
|
38
|
+
return this.cryptoResource.signEncrypt(input);
|
|
39
|
+
}
|
|
37
40
|
async decrypt(input) {
|
|
38
41
|
return this.cryptoResource.decrypt(input);
|
|
39
42
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,0CA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,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAmB;QAC/B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,KAAyB;QAEzB,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAEO,mBAAmB,CACzB,IAAoC;QAEpC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7C,OAAO,IAAA,oBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,wBAAwB,IAAI,IAAI,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAvED,wCAuEC"}
|
package/dist/crittora.d.ts
CHANGED
|
@@ -9,10 +9,14 @@ export declare class Crittora {
|
|
|
9
9
|
constructor(options?: LegacyCrittoraOptions);
|
|
10
10
|
authenticate(username: string, password: string): Promise<LegacyAuthResponse>;
|
|
11
11
|
encrypt(idToken: string, data: string, permissions?: string[]): Promise<string>;
|
|
12
|
+
signEncrypt(idToken: string, data: string, permissions?: string[]): Promise<string>;
|
|
12
13
|
decrypt(idToken: string, encryptedData: string, permissions?: string[]): Promise<string>;
|
|
13
14
|
decryptVerify(idToken: string, encryptedData: string, permissions?: string[]): Promise<{
|
|
14
15
|
decrypted_data: string;
|
|
15
16
|
is_valid_signature: boolean;
|
|
17
|
+
signed_by?: string;
|
|
18
|
+
signed_timestamp?: string;
|
|
19
|
+
repudiator?: string;
|
|
16
20
|
}>;
|
|
17
21
|
private toLegacyPermissions;
|
|
18
22
|
}
|
package/dist/crittora.js
CHANGED
|
@@ -42,6 +42,15 @@ class Crittora {
|
|
|
42
42
|
});
|
|
43
43
|
return result.encryptedData;
|
|
44
44
|
}
|
|
45
|
+
async signEncrypt(idToken, data, permissions) {
|
|
46
|
+
const result = await this.client
|
|
47
|
+
.withAuth({ type: "bearer", token: idToken })
|
|
48
|
+
.signEncrypt({
|
|
49
|
+
data,
|
|
50
|
+
permissions: this.toLegacyPermissions(permissions),
|
|
51
|
+
});
|
|
52
|
+
return result.encryptedData;
|
|
53
|
+
}
|
|
45
54
|
async decrypt(idToken, encryptedData, permissions) {
|
|
46
55
|
const result = await this.client
|
|
47
56
|
.withAuth({ type: "bearer", token: idToken })
|
|
@@ -61,6 +70,9 @@ class Crittora {
|
|
|
61
70
|
return {
|
|
62
71
|
decrypted_data: result.decryptedData,
|
|
63
72
|
is_valid_signature: result.isValidSignature,
|
|
73
|
+
signed_by: result.signedBy,
|
|
74
|
+
signed_timestamp: result.signedTimestamp,
|
|
75
|
+
repudiator: result.repudiator,
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
78
|
toLegacyPermissions(permissions) {
|
package/dist/crittora.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crittora.js","sourceRoot":"","sources":["../src/crittora.ts"],"names":[],"mappings":";;;AAAA,4CAAqD;AACrD,qCAA0C;AAY1C,MAAa,QAAQ;IAInB,YAA6B,UAAiC,EAAE;QAAnC,YAAO,GAAP,OAAO,CAA4B;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAA,6BAAmB,EAAC;YACjC,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,IAAI,qBAAqB;YAChE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,IAAI,4BAA4B;YACnE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ;YACnC,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ;SACpC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAc,CAAC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C,aAAa,CACjB,OAAe,EACf,aAAqB,EACrB,WAAsB;QAQtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM;aAC7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;aAC5C,aAAa,CAAC;YACb,aAAa;YACb,WAAW,EAAE,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC;SACnD,CAAC,CAAC;QAEL,OAAO;YACL,cAAc,EAAE,MAAM,CAAC,aAAa;YACpC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB;YAC3C,SAAS,EAAE,MAAM,CAAC,QAAQ;YAC1B,gBAAgB,EAAE,MAAM,CAAC,eAAe;YACxC,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,WAAsB;QAChD,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO;YACL;gBACE,SAAS,EAAE,SAAS;gBACpB,OAAO,EAAE,WAAW;aACrB;SACF,CAAC;IACJ,CAAC;CACF;AA1HD,4BA0HC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecryptInput, DecryptResult, DecryptVerifyInput, DecryptVerifyResult, EncryptInput, EncryptResult } from "../types";
|
|
1
|
+
import { DecryptInput, DecryptResult, DecryptVerifyInput, DecryptVerifyResult, EncryptInput, EncryptResult, SignEncryptInput, SignEncryptResult } from "../types";
|
|
2
2
|
import { AuthProvider } from "../auth/types";
|
|
3
3
|
import { HttpTransport } from "../transport/httpTransport";
|
|
4
4
|
export declare class CryptoResource {
|
|
@@ -6,6 +6,7 @@ export declare class CryptoResource {
|
|
|
6
6
|
private readonly authProvider?;
|
|
7
7
|
constructor(transport: HttpTransport, authProvider?: AuthProvider | undefined);
|
|
8
8
|
encrypt(input: EncryptInput): Promise<EncryptResult>;
|
|
9
|
+
signEncrypt(input: SignEncryptInput): Promise<SignEncryptResult>;
|
|
9
10
|
decrypt(input: DecryptInput): Promise<DecryptResult>;
|
|
10
11
|
decryptVerify(input: DecryptVerifyInput): Promise<DecryptVerifyResult>;
|
|
11
12
|
private serializePermissions;
|
package/dist/resources/crypto.js
CHANGED
|
@@ -21,13 +21,32 @@ class CryptoResource {
|
|
|
21
21
|
}, this.authProvider);
|
|
22
22
|
return {
|
|
23
23
|
encryptedData: result.encrypted_data,
|
|
24
|
-
transactionId: result.transactionId,
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
catch (error) {
|
|
28
27
|
throw this.wrapEncryptError("Encryption failed", error);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
30
|
+
async signEncrypt(input) {
|
|
31
|
+
try {
|
|
32
|
+
const result = await this.transport.request({
|
|
33
|
+
path: "/sign-encrypt",
|
|
34
|
+
body: {
|
|
35
|
+
data: input.data,
|
|
36
|
+
requested_actions: ["e", "s"],
|
|
37
|
+
...(input.permissions && {
|
|
38
|
+
permissions: this.serializePermissions(input.permissions),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
}, this.authProvider);
|
|
42
|
+
return {
|
|
43
|
+
encryptedData: result.encrypted_data,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw this.wrapEncryptError("Sign-encrypt failed", error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
31
50
|
async decrypt(input) {
|
|
32
51
|
try {
|
|
33
52
|
const result = await this.transport.request({
|
|
@@ -41,7 +60,6 @@ class CryptoResource {
|
|
|
41
60
|
}, this.authProvider);
|
|
42
61
|
return {
|
|
43
62
|
decryptedData: result.decrypted_data,
|
|
44
|
-
transactionId: result.transactionId,
|
|
45
63
|
};
|
|
46
64
|
}
|
|
47
65
|
catch (error) {
|
|
@@ -62,7 +80,9 @@ class CryptoResource {
|
|
|
62
80
|
return {
|
|
63
81
|
decryptedData: result.decrypted_data,
|
|
64
82
|
isValidSignature: result.is_valid_signature,
|
|
65
|
-
|
|
83
|
+
signedBy: result.signed_by,
|
|
84
|
+
signedTimestamp: result.signed_timestamp,
|
|
85
|
+
repudiator: result.repudiator,
|
|
66
86
|
};
|
|
67
87
|
}
|
|
68
88
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/resources/crypto.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/resources/crypto.ts"],"names":[],"mappings":";;;AAiBA,sCAAqE;AAErE,MAAa,cAAc;IACzB,YACmB,SAAwB,EACxB,YAA2B;QAD3B,cAAS,GAAT,SAAS,CAAe;QACxB,iBAAY,GAAZ,YAAY,CAAe;IAC3C,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAAmB;QAC/B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACzC;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE;oBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,iBAAiB,EAAE,CAAC,GAAG,CAAC;oBACxB,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI;wBACvB,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC;qBAC1D,CAAC;iBACH;aACF,EACD,IAAI,CAAC,YAAY,CAClB,CAAC;YAEF,OAAO;gBACL,aAAa,EAAE,MAAM,CAAC,cAAc;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAuB;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACzC;gBACE,I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D,IAAI,KAAK,YAAY,qBAAY,EAAE,CAAC;YAClC,OAAO,IAAI,qBAAY,CAAC,OAAO,EAAE;gBAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,qBAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AA5ID,wCA4IC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -23,7 +23,13 @@ export interface EncryptInput {
|
|
|
23
23
|
}
|
|
24
24
|
export interface EncryptResult {
|
|
25
25
|
encryptedData: string;
|
|
26
|
-
|
|
26
|
+
}
|
|
27
|
+
export interface SignEncryptInput {
|
|
28
|
+
data: string;
|
|
29
|
+
permissions?: Permission[];
|
|
30
|
+
}
|
|
31
|
+
export interface SignEncryptResult {
|
|
32
|
+
encryptedData: string;
|
|
27
33
|
}
|
|
28
34
|
export interface DecryptInput {
|
|
29
35
|
encryptedData: string;
|
|
@@ -31,7 +37,6 @@ export interface DecryptInput {
|
|
|
31
37
|
}
|
|
32
38
|
export interface DecryptResult {
|
|
33
39
|
decryptedData: string;
|
|
34
|
-
transactionId?: string;
|
|
35
40
|
}
|
|
36
41
|
export interface DecryptVerifyInput {
|
|
37
42
|
encryptedData: string;
|
|
@@ -40,7 +45,9 @@ export interface DecryptVerifyInput {
|
|
|
40
45
|
export interface DecryptVerifyResult {
|
|
41
46
|
decryptedData: string;
|
|
42
47
|
isValidSignature: boolean;
|
|
43
|
-
|
|
48
|
+
signedBy?: string;
|
|
49
|
+
signedTimestamp?: string;
|
|
50
|
+
repudiator?: string;
|
|
44
51
|
}
|
|
45
52
|
export interface AuthTokens {
|
|
46
53
|
idToken: string;
|
|
@@ -83,16 +90,19 @@ export interface WirePermission {
|
|
|
83
90
|
}
|
|
84
91
|
export interface WireEncryptResult {
|
|
85
92
|
encrypted_data: string;
|
|
86
|
-
|
|
93
|
+
}
|
|
94
|
+
export interface WireSignEncryptResult {
|
|
95
|
+
encrypted_data: string;
|
|
87
96
|
}
|
|
88
97
|
export interface WireDecryptResult {
|
|
89
98
|
decrypted_data: string;
|
|
90
|
-
transactionId?: string;
|
|
91
99
|
}
|
|
92
100
|
export interface WireDecryptVerifyResult {
|
|
93
101
|
decrypted_data: string;
|
|
94
102
|
is_valid_signature: boolean;
|
|
95
|
-
|
|
103
|
+
signed_by?: string;
|
|
104
|
+
signed_timestamp?: string;
|
|
105
|
+
repudiator?: string;
|
|
96
106
|
}
|
|
97
107
|
export interface LegacyAuthResponse {
|
|
98
108
|
IdToken: string;
|
package/docs/API.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
This document describes the public SDK surface exposed by `@crittora/sdk-js`.
|
|
4
4
|
|
|
5
|
+
The public API is intentionally limited to two workflows:
|
|
6
|
+
|
|
7
|
+
- `encrypt(...)` -> `decrypt(...)`
|
|
8
|
+
- `signEncrypt(...)` -> `decryptVerify(...)`
|
|
9
|
+
|
|
5
10
|
## Exports
|
|
6
11
|
|
|
7
12
|
Primary exports:
|
|
@@ -63,10 +68,15 @@ Result:
|
|
|
63
68
|
```ts
|
|
64
69
|
type EncryptResult = {
|
|
65
70
|
encryptedData: string;
|
|
66
|
-
transactionId?: string;
|
|
67
71
|
};
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
Behavior notes:
|
|
75
|
+
|
|
76
|
+
- The SDK sends `requested_actions: ["e"]` on the wire.
|
|
77
|
+
- The API returns a single org-encrypted envelope as `encrypted_data`.
|
|
78
|
+
- The intended follow-up operation is `decrypt(...)`.
|
|
79
|
+
|
|
70
80
|
#### `decrypt(input)`
|
|
71
81
|
|
|
72
82
|
```ts
|
|
@@ -87,10 +97,44 @@ Result:
|
|
|
87
97
|
```ts
|
|
88
98
|
type DecryptResult = {
|
|
89
99
|
decryptedData: string;
|
|
90
|
-
transactionId?: string;
|
|
91
100
|
};
|
|
92
101
|
```
|
|
93
102
|
|
|
103
|
+
Behavior notes:
|
|
104
|
+
|
|
105
|
+
- Pass the exact `encryptedData` string returned by `encrypt(...)`.
|
|
106
|
+
- The router unwraps the org-encrypted envelope before the Lambda performs decrypt.
|
|
107
|
+
- Successful responses return plaintext only.
|
|
108
|
+
|
|
109
|
+
#### `signEncrypt(input)`
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
signEncrypt(input: SignEncryptInput): Promise<SignEncryptResult>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Input:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
type SignEncryptInput = {
|
|
119
|
+
data: string;
|
|
120
|
+
permissions?: Permission[];
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Result:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
type SignEncryptResult = {
|
|
128
|
+
encryptedData: string;
|
|
129
|
+
};
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Behavior notes:
|
|
133
|
+
|
|
134
|
+
- The SDK sends `requested_actions: ["e", "s"]` on the wire.
|
|
135
|
+
- The API returns a single org-encrypted envelope as `encrypted_data`.
|
|
136
|
+
- The intended follow-up operation is `decryptVerify(...)`.
|
|
137
|
+
|
|
94
138
|
#### `decryptVerify(input)`
|
|
95
139
|
|
|
96
140
|
```ts
|
|
@@ -112,10 +156,19 @@ Result:
|
|
|
112
156
|
type DecryptVerifyResult = {
|
|
113
157
|
decryptedData: string;
|
|
114
158
|
isValidSignature: boolean;
|
|
115
|
-
|
|
159
|
+
signedBy?: string;
|
|
160
|
+
signedTimestamp?: string;
|
|
161
|
+
repudiator?: string;
|
|
116
162
|
};
|
|
117
163
|
```
|
|
118
164
|
|
|
165
|
+
Behavior notes:
|
|
166
|
+
|
|
167
|
+
- Pass the exact `encryptedData` string returned by `signEncrypt(...)`.
|
|
168
|
+
- The router unwraps the org-encrypted envelope before the Lambda performs decrypt and verify.
|
|
169
|
+
- Successful verification may include `signedBy` and `signedTimestamp`.
|
|
170
|
+
- Failed verification may still return `decryptedData`, with `isValidSignature: false` and `repudiator`.
|
|
171
|
+
|
|
119
172
|
#### `withAuth(auth)`
|
|
120
173
|
|
|
121
174
|
```ts
|
|
@@ -187,12 +240,23 @@ Methods:
|
|
|
187
240
|
```ts
|
|
188
241
|
authenticate(username: string, password: string): Promise<LegacyAuthResponse>
|
|
189
242
|
encrypt(idToken: string, data: string, permissions?: string[]): Promise<string>
|
|
243
|
+
signEncrypt(
|
|
244
|
+
idToken: string,
|
|
245
|
+
data: string,
|
|
246
|
+
permissions?: string[]
|
|
247
|
+
): Promise<string>
|
|
190
248
|
decrypt(idToken: string, encryptedData: string, permissions?: string[]): Promise<string>
|
|
191
249
|
decryptVerify(
|
|
192
250
|
idToken: string,
|
|
193
251
|
encryptedData: string,
|
|
194
252
|
permissions?: string[]
|
|
195
|
-
): Promise<{
|
|
253
|
+
): Promise<{
|
|
254
|
+
decrypted_data: string;
|
|
255
|
+
is_valid_signature: boolean;
|
|
256
|
+
signed_by?: string;
|
|
257
|
+
signed_timestamp?: string;
|
|
258
|
+
repudiator?: string;
|
|
259
|
+
}>
|
|
196
260
|
```
|
|
197
261
|
|
|
198
262
|
This interface is transitional. New integrations should use `CrittoraClient`.
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -10,6 +10,18 @@ The SDK is designed to be:
|
|
|
10
10
|
- safe to run in multi-tenant or multi-environment processes
|
|
11
11
|
- adaptable to different auth models
|
|
12
12
|
- operationally predictable under failure
|
|
13
|
+
- intentionally narrow in surface area
|
|
14
|
+
|
|
15
|
+
## Product scope
|
|
16
|
+
|
|
17
|
+
This package is not positioned as a general-purpose cryptography toolkit.
|
|
18
|
+
|
|
19
|
+
It supports exactly four high-level operations arranged into two workflows:
|
|
20
|
+
|
|
21
|
+
- confidentiality only: `encrypt()` and `decrypt()`
|
|
22
|
+
- confidentiality plus authenticity: `signEncrypt()` and `decryptVerify()`
|
|
23
|
+
|
|
24
|
+
That narrow surface is intentional. The SDK mirrors the backend product contract rather than exposing lower-level standalone sign or verify primitives.
|
|
13
25
|
|
|
14
26
|
## Layering
|
|
15
27
|
|
package/docs/MIGRATION.md
CHANGED
|
@@ -82,6 +82,35 @@ const encrypted = await client
|
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
84
|
});
|
|
85
|
+
|
|
86
|
+
console.log(encrypted.encryptedData);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Sign and encrypt
|
|
90
|
+
|
|
91
|
+
Before:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const result = await sdk.signEncrypt(idToken, data, ["read"]);
|
|
95
|
+
console.log(result);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
After:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const result = await client
|
|
102
|
+
.withAuth({ type: "bearer", token: idToken })
|
|
103
|
+
.signEncrypt({
|
|
104
|
+
data,
|
|
105
|
+
permissions: [
|
|
106
|
+
{
|
|
107
|
+
partnerId: "default",
|
|
108
|
+
actions: ["read"],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log(result.encryptedData);
|
|
85
114
|
```
|
|
86
115
|
|
|
87
116
|
### Decrypt
|
|
@@ -100,6 +129,8 @@ const decrypted = await client
|
|
|
100
129
|
.decrypt({
|
|
101
130
|
encryptedData,
|
|
102
131
|
});
|
|
132
|
+
|
|
133
|
+
console.log(decrypted.decryptedData);
|
|
103
134
|
```
|
|
104
135
|
|
|
105
136
|
### Decrypt and verify
|
|
@@ -108,7 +139,12 @@ Before:
|
|
|
108
139
|
|
|
109
140
|
```ts
|
|
110
141
|
const result = await sdk.decryptVerify(idToken, encryptedData);
|
|
111
|
-
console.log(
|
|
142
|
+
console.log(
|
|
143
|
+
result.decrypted_data,
|
|
144
|
+
result.is_valid_signature,
|
|
145
|
+
result.signed_by,
|
|
146
|
+
result.signed_timestamp
|
|
147
|
+
);
|
|
112
148
|
```
|
|
113
149
|
|
|
114
150
|
After:
|
|
@@ -121,6 +157,7 @@ const result = await client
|
|
|
121
157
|
});
|
|
122
158
|
|
|
123
159
|
console.log(result.decryptedData, result.isValidSignature);
|
|
160
|
+
console.log(result.signedBy, result.signedTimestamp);
|
|
124
161
|
```
|
|
125
162
|
|
|
126
163
|
## Type changes
|
|
@@ -130,6 +167,8 @@ Main public naming changes:
|
|
|
130
167
|
- `encrypted_data` -> `encryptedData`
|
|
131
168
|
- `decrypted_data` -> `decryptedData`
|
|
132
169
|
- `is_valid_signature` -> `isValidSignature`
|
|
170
|
+
- `signed_by` -> `signedBy`
|
|
171
|
+
- `signed_timestamp` -> `signedTimestamp`
|
|
133
172
|
|
|
134
173
|
Permission changes:
|
|
135
174
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
This document outlines the release process for `@crittora/sdk-js`.
|
|
4
|
+
|
|
5
|
+
## Release posture
|
|
6
|
+
|
|
7
|
+
The package ships a v2-style client architecture and a temporary legacy compatibility shim. Versioning should reflect that reality:
|
|
8
|
+
|
|
9
|
+
- use `major` for breaking API changes, removal of the legacy `Crittora` shim, or runtime contract changes
|
|
10
|
+
- use `minor` for additive API surface such as new methods, auth providers, or response fields
|
|
11
|
+
- use `patch` for bug fixes, packaging fixes, and documentation corrections
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
1. Ensure you have NPM access to the `@crittora` organization.
|
|
16
|
+
2. Make sure you are logged in with `npm login`.
|
|
17
|
+
3. Confirm local verification passes.
|
|
18
|
+
4. Confirm README and docs match the shipped API.
|
|
19
|
+
|
|
20
|
+
## Runtime and packaging assumptions
|
|
21
|
+
|
|
22
|
+
The published package currently targets:
|
|
23
|
+
|
|
24
|
+
- Node.js 18 or later
|
|
25
|
+
- CommonJS output with TypeScript declarations
|
|
26
|
+
- explicit client configuration rather than package-managed `.env` loading
|
|
27
|
+
|
|
28
|
+
Published package contents:
|
|
29
|
+
|
|
30
|
+
- `dist/`
|
|
31
|
+
- `docs/`
|
|
32
|
+
- `README.md`
|
|
33
|
+
- `CHANGELOG.md`
|
|
34
|
+
- `LICENSE`
|
|
35
|
+
|
|
36
|
+
## Standard release commands
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm run verify
|
|
40
|
+
npm run release:patch
|
|
41
|
+
npm run release:minor
|
|
42
|
+
npm run release:major
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Each release command performs:
|
|
46
|
+
|
|
47
|
+
1. clean build artifacts
|
|
48
|
+
2. TypeScript build
|
|
49
|
+
3. test execution
|
|
50
|
+
4. semantic version bump
|
|
51
|
+
5. `npm publish`
|
|
52
|
+
|
|
53
|
+
## Recommended release flow
|
|
54
|
+
|
|
55
|
+
1. Verify locally:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run verify
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. Inspect the package payload:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm pack --dry-run
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
3. Choose the correct semantic version bump:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm run release:patch
|
|
71
|
+
npm run release:minor
|
|
72
|
+
npm run release:major
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
4. Verify the published package:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm view @crittora/sdk-js versions
|
|
79
|
+
npm install @crittora/sdk-js@latest
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Pre-release checklist
|
|
83
|
+
|
|
84
|
+
- README examples match the current code
|
|
85
|
+
- `docs/API.md` matches the exported surface
|
|
86
|
+
- `docs/MIGRATION.md` matches any deprecation and breaking-change policy
|
|
87
|
+
- Node engine requirement is accurate
|
|
88
|
+
- tests pass without warnings indicating broken configuration
|
|
89
|
+
|
|
90
|
+
## Troubleshooting
|
|
91
|
+
|
|
92
|
+
If a release fails:
|
|
93
|
+
|
|
94
|
+
1. run `npm run build`
|
|
95
|
+
2. run `npm test`
|
|
96
|
+
3. inspect `npm pack --dry-run`
|
|
97
|
+
4. confirm NPM auth with `npm whoami`
|
|
98
|
+
5. confirm package metadata in `package.json`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crittora/sdk-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Crittora JavaScript SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
30
30
|
"encryption",
|
|
31
|
-
"signing",
|
|
32
31
|
"sdk",
|
|
33
|
-
"
|
|
32
|
+
"secure-messaging",
|
|
33
|
+
"data-protection",
|
|
34
34
|
"crittora"
|
|
35
35
|
],
|
|
36
36
|
"author": "Erik Rowan <erik@crittora.com>, Gerardo I. Ornelas <gerardo@crittora.com>",
|