@cubist-labs/cubesigner-sdk 0.2.17 → 0.2.21
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/dist/package.json +6 -6
- package/dist/src/api.d.ts +145 -15
- package/dist/src/api.js +340 -252
- package/dist/src/client.d.ts +28 -8
- package/dist/src/client.js +33 -13
- package/dist/src/events.d.ts +84 -0
- package/dist/src/events.js +195 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +10 -6
- package/dist/src/mfa.js +3 -3
- package/dist/src/schema.d.ts +81 -0
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +1 -0
- package/dist/src/schema_types.js +1 -1
- package/dist/src/session/cognito_manager.js +2 -2
- package/dist/src/session/session_manager.d.ts +6 -4
- package/dist/src/session/session_manager.js +11 -5
- package/dist/src/session/signer_session_manager.d.ts +8 -2
- package/dist/src/session/signer_session_manager.js +43 -16
- package/dist/src/util.d.ts +0 -30
- package/dist/src/util.js +2 -38
- package/package.json +6 -6
- package/src/api.ts +424 -250
- package/src/client.ts +34 -12
- package/src/events.ts +197 -0
- package/src/index.ts +6 -4
- package/src/mfa.ts +2 -2
- package/src/schema.ts +81 -0
- package/src/schema_types.ts +2 -0
- package/src/session/cognito_manager.ts +2 -2
- package/src/session/session_manager.ts +11 -5
- package/src/session/signer_session_manager.ts +51 -18
- package/src/util.ts +0 -45
package/src/util.ts
CHANGED
|
@@ -20,51 +20,6 @@ export function configDir(): string {
|
|
|
20
20
|
return path.join(configDir, "cubesigner");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type ResponseType<D, T> = { data?: D; error?: T; response?: Response };
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Error response type, thrown on non-successful responses.
|
|
27
|
-
*/
|
|
28
|
-
export class ErrResponse extends Error {
|
|
29
|
-
/** Description */
|
|
30
|
-
readonly description?: string;
|
|
31
|
-
/** HTTP status code text (derived from `this.status`) */
|
|
32
|
-
readonly statusText?: string;
|
|
33
|
-
/** HTTP status code */
|
|
34
|
-
readonly status?: number;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructor
|
|
38
|
-
* @param {Partial<ErrResponse>} init Initializer
|
|
39
|
-
*/
|
|
40
|
-
constructor(init: Partial<ErrResponse>) {
|
|
41
|
-
super(init.message);
|
|
42
|
-
Object.assign(this, init);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Throw if on error response. Otherwise, return the response data.
|
|
48
|
-
* @param {ResponseType} resp The response to check
|
|
49
|
-
* @param {string} description Description to include in the thrown error
|
|
50
|
-
* @return {D} The response data.
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
export function assertOk<D, T>(resp: ResponseType<D, T>, description?: string): D {
|
|
54
|
-
if (resp.error) {
|
|
55
|
-
throw new ErrResponse({
|
|
56
|
-
description,
|
|
57
|
-
message: (resp.error as any).message, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
58
|
-
statusText: resp.response?.statusText,
|
|
59
|
-
status: resp.response?.status,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (resp.data === undefined) {
|
|
63
|
-
throw new Error("Response data is undefined");
|
|
64
|
-
}
|
|
65
|
-
return resp.data;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
23
|
/**
|
|
69
24
|
* Browser-friendly helper for decoding a 'base64'-encoded string into a byte array.
|
|
70
25
|
*
|