@cubist-labs/cubesigner-sdk 0.4.237 → 0.4.241
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 +3 -2
- package/dist/src/audit_log.d.ts +336 -0
- package/dist/src/audit_log.d.ts.map +1 -0
- package/dist/src/audit_log.js +180 -0
- package/dist/src/client/api_client.d.ts +26 -13
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/client/api_client.js +48 -30
- package/dist/src/client/base_client.d.ts +7 -0
- package/dist/src/client/base_client.d.ts.map +1 -1
- package/dist/src/client/base_client.js +14 -6
- package/dist/src/client.d.ts +24 -32
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +21 -29
- package/dist/src/schema_types.d.ts +1 -1
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +1 -1
- package/package.json +3 -2
- package/src/audit_log.ts +195 -0
- package/src/client/api_client.ts +58 -19
- package/src/client/base_client.ts +21 -8
- package/src/client.ts +23 -57
- package/src/schema_types.ts +1 -1
|
@@ -9,6 +9,7 @@ import type { SessionData, SessionManager, SessionMetadata } from "./session";
|
|
|
9
9
|
import { MemorySessionManager, metadata, parseBase64SessionData } from "./session";
|
|
10
10
|
import type { NewSessionResponse, ErrorResponse } from "../schema_types";
|
|
11
11
|
import type { EnvInterface } from "../env";
|
|
12
|
+
import { mergeHeaders } from "openapi-fetch";
|
|
12
13
|
|
|
13
14
|
/** CubeSigner SDK package name */
|
|
14
15
|
export const NAME: string = pkg.name;
|
|
@@ -163,14 +164,16 @@ export class BaseClient extends EventEmitter<ClientEvents> {
|
|
|
163
164
|
// If we have an activeSession, let it dictate the baseUrl. Otherwise fall back to the one set at construction
|
|
164
165
|
baseUrl,
|
|
165
166
|
...opts,
|
|
166
|
-
headers:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
headers: mergeHeaders(
|
|
168
|
+
{
|
|
169
|
+
"User-Agent": browserUserAgent ?? `${NAME}@${VERSION}`,
|
|
170
|
+
"X-Cubist-Ts-Sdk": `${NAME}@${VERSION}`,
|
|
171
|
+
Origin: this.config.origin,
|
|
172
|
+
},
|
|
173
|
+
authHeader(token),
|
|
174
|
+
this.config.headers,
|
|
175
|
+
opts.headers,
|
|
176
|
+
),
|
|
174
177
|
params: {
|
|
175
178
|
...opts.params,
|
|
176
179
|
path: {
|
|
@@ -308,3 +311,13 @@ export type OmitAutoParams<O> = DeepOmit<
|
|
|
308
311
|
params: { path: { org_id: string } };
|
|
309
312
|
}
|
|
310
313
|
> & { params?: { path?: Record<string, unknown> } };
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Creates {@link HeadersInit} containing a single "Authorization" header with a given value.
|
|
317
|
+
*
|
|
318
|
+
* @param token The "Authorization" header value
|
|
319
|
+
* @returns A {@link HeadersInit} object containing a single "Authorization" header with a given value.
|
|
320
|
+
*/
|
|
321
|
+
export function authHeader(token: string): HeadersInit {
|
|
322
|
+
return { Authorization: token };
|
|
323
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { ApiClient } from "./client/api_client";
|
|
2
|
-
import type { IdentityProof, RatchetConfig
|
|
2
|
+
import type { EmailOtpResponse, IdentityProof, RatchetConfig } from "./schema_types";
|
|
3
3
|
|
|
4
4
|
// used in doc comments
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
6
|
import { AddFidoChallenge, TotpChallenge } from "./mfa";
|
|
7
7
|
import { Org } from "./org";
|
|
8
|
-
import type {
|
|
9
|
-
CubeSignerResponse,
|
|
10
|
-
EnvInterface,
|
|
11
|
-
MfaReceipts,
|
|
12
|
-
Scope,
|
|
13
|
-
SessionData,
|
|
14
|
-
SessionInfo,
|
|
15
|
-
SessionManager,
|
|
16
|
-
} from ".";
|
|
8
|
+
import type { MfaReceipts, SessionData, SessionInfo, SessionManager } from ".";
|
|
17
9
|
import { Key } from ".";
|
|
18
10
|
|
|
19
11
|
/** Options for logging in with OIDC token */
|
|
@@ -122,71 +114,45 @@ export class CubeSignerClient {
|
|
|
122
114
|
}
|
|
123
115
|
|
|
124
116
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* @
|
|
128
|
-
*
|
|
129
|
-
* @param
|
|
130
|
-
* @
|
|
131
|
-
* @param lifetimes Lifetimes of the new session.
|
|
132
|
-
* @param mfaReceipt Optional MFA receipt(s)
|
|
133
|
-
* @param purpose Optional session description.
|
|
134
|
-
* @returns The session data.
|
|
117
|
+
* Create a new OIDC-backed session.
|
|
118
|
+
*
|
|
119
|
+
* Same as {@link ApiClient.oidcSessionCreate}, see its documentation for more details.
|
|
120
|
+
*
|
|
121
|
+
* @param args Request arguments
|
|
122
|
+
* @returns The new session data
|
|
135
123
|
*/
|
|
136
124
|
static async createOidcSession(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
scopes: Array<Scope>,
|
|
141
|
-
lifetimes?: RatchetConfig,
|
|
142
|
-
mfaReceipt?: MfaReceipts,
|
|
143
|
-
purpose?: string,
|
|
144
|
-
): Promise<CubeSignerResponse<SessionData>> {
|
|
145
|
-
return await ApiClient.oidcSessionCreate(
|
|
146
|
-
env,
|
|
147
|
-
orgId,
|
|
148
|
-
token,
|
|
149
|
-
scopes,
|
|
150
|
-
lifetimes,
|
|
151
|
-
mfaReceipt,
|
|
152
|
-
purpose,
|
|
153
|
-
);
|
|
125
|
+
...args: Parameters<typeof ApiClient.oidcSessionCreate>
|
|
126
|
+
): Promise<Awaited<ReturnType<typeof ApiClient.oidcSessionCreate>>> {
|
|
127
|
+
return await ApiClient.oidcSessionCreate(...args);
|
|
154
128
|
}
|
|
155
129
|
|
|
156
130
|
/**
|
|
157
|
-
*
|
|
131
|
+
* Prove an OIDC identity.
|
|
132
|
+
*
|
|
133
|
+
* Same as {@link ApiClient.identityProveOidc}, see its documentation for more details.
|
|
158
134
|
*
|
|
159
|
-
* @param
|
|
160
|
-
* @param orgId The org id in which to generate proof
|
|
161
|
-
* @param token The oidc token
|
|
135
|
+
* @param args Request arguments
|
|
162
136
|
* @returns Proof of authentication
|
|
163
137
|
*/
|
|
164
138
|
static async proveOidcIdentity(
|
|
165
|
-
|
|
166
|
-
orgId: string,
|
|
167
|
-
token: string,
|
|
139
|
+
...args: Parameters<typeof ApiClient.identityProveOidc>
|
|
168
140
|
): Promise<IdentityProof> {
|
|
169
|
-
return await ApiClient.identityProveOidc(
|
|
141
|
+
return await ApiClient.identityProveOidc(...args);
|
|
170
142
|
}
|
|
171
143
|
|
|
172
144
|
/**
|
|
173
|
-
*
|
|
174
|
-
* Returns an unsigned OIDC token and sends an email to the user containing the signature of that token.
|
|
175
|
-
* The OIDC token can be reconstructed by appending the signature to the partial token like so:
|
|
145
|
+
* Initialize email OTP authentication.
|
|
176
146
|
*
|
|
177
|
-
*
|
|
147
|
+
* Same as {@link ApiClient.initEmailOtpAuth}, see its documentation for more details.
|
|
178
148
|
*
|
|
179
|
-
* @param
|
|
180
|
-
* @
|
|
181
|
-
* @param email The email to send the signature to
|
|
182
|
-
* @returns The partial OIDC token that must be combined with the signature in the email
|
|
149
|
+
* @param args Request arguments
|
|
150
|
+
* @returns — The partial OIDC token that must be combined with the signature in the email
|
|
183
151
|
*/
|
|
184
152
|
static async initEmailOtpAuth(
|
|
185
|
-
|
|
186
|
-
orgId: string,
|
|
187
|
-
email: string,
|
|
153
|
+
...args: Parameters<typeof ApiClient.initEmailOtpAuth>
|
|
188
154
|
): Promise<EmailOtpResponse> {
|
|
189
|
-
return await ApiClient.initEmailOtpAuth(
|
|
155
|
+
return await ApiClient.initEmailOtpAuth(...args);
|
|
190
156
|
}
|
|
191
157
|
|
|
192
158
|
/**
|
package/src/schema_types.ts
CHANGED
|
@@ -221,7 +221,7 @@ export type QueryMetricsRequest = schemas["QueryMetricsRequest"];
|
|
|
221
221
|
export type QueryMetricsResponse = schemas["QueryMetricsResponse"];
|
|
222
222
|
export type AuditLogRequest = schemas["AuditLogRequest"];
|
|
223
223
|
export type AuditLogResponse = schemas["PaginatedAuditLogResponse"];
|
|
224
|
-
export type AuditLogEntry
|
|
224
|
+
export type { AuditLogEntry } from "./audit_log";
|
|
225
225
|
|
|
226
226
|
export type DiffieHellmanRequest = schemas["DiffieHellmanRequest"];
|
|
227
227
|
export type DiffieHellmanResponse = schemas["DiffieHellmanResponse"];
|