@scalekit-sdk/node 1.0.5 → 1.0.7
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 +32 -6
- package/lib/connection.js +5 -20
- package/lib/connection.js.map +1 -1
- package/lib/core.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +64 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +63 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +278 -149
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +362 -70
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +10 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +9 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +34 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +64 -2
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +6 -0
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +8 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +19 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +18 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +71 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +120 -2
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
- package/lib/scalekit.d.ts +15 -0
- package/lib/scalekit.js +34 -6
- package/lib/scalekit.js.map +1 -1
- package/lib/types/auth.d.ts +6 -0
- package/package.json +4 -4
- package/src/core.ts +1 -1
- package/src/index.ts +1 -0
- package/src/scalekit.ts +33 -7
- package/src/types/auth.ts +7 -0
package/src/scalekit.ts
CHANGED
|
@@ -7,7 +7,7 @@ import CoreClient from './core';
|
|
|
7
7
|
import DomainClient from './domain';
|
|
8
8
|
import OrganizationClient from './organization';
|
|
9
9
|
import { AuthorizationUrlOptions, AuthenticationOptions, GrantType, AuthenticationResponse } from './types/scalekit';
|
|
10
|
-
import { IdTokenClaim, User } from './types/auth';
|
|
10
|
+
import { IdpInitiatedLoginClaims, IdTokenClaim, User } from './types/auth';
|
|
11
11
|
|
|
12
12
|
const authorizeEndpoint = "oauth/authorize";
|
|
13
13
|
|
|
@@ -98,7 +98,8 @@ export default class ScalekitClient {
|
|
|
98
98
|
...(options.connectionId && { connection_id: options.connectionId }),
|
|
99
99
|
...(options.organizationId && { organization_id: options.organizationId }),
|
|
100
100
|
...(options.codeChallenge && { code_challenge: options.codeChallenge }),
|
|
101
|
-
...(options.codeChallengeMethod && { code_challenge_method: options.codeChallengeMethod })
|
|
101
|
+
...(options.codeChallengeMethod && { code_challenge_method: options.codeChallengeMethod }),
|
|
102
|
+
...(options.provider && { provider: options.provider })
|
|
102
103
|
})
|
|
103
104
|
|
|
104
105
|
return `${this.coreClient.envUrl}/${authorizeEndpoint}?${qs}`
|
|
@@ -142,6 +143,16 @@ export default class ScalekitClient {
|
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Get the idp initiated login claims
|
|
148
|
+
*
|
|
149
|
+
* @param {string} idpInitiatedLoginToken The idp_initiated_login query param from the URL
|
|
150
|
+
* @returns {object} Returns the idp initiated login claims
|
|
151
|
+
*/
|
|
152
|
+
async getIdpInitiatedLoginClaims(idpInitiatedLoginToken: string): Promise<IdpInitiatedLoginClaims> {
|
|
153
|
+
return await this.validateToken<IdpInitiatedLoginClaims>(idpInitiatedLoginToken);
|
|
154
|
+
}
|
|
155
|
+
|
|
145
156
|
/**
|
|
146
157
|
* Validates the access token.
|
|
147
158
|
*
|
|
@@ -149,15 +160,30 @@ export default class ScalekitClient {
|
|
|
149
160
|
* @return {Promise<boolean>} Returns true if the token is valid, false otherwise.
|
|
150
161
|
*/
|
|
151
162
|
async validateAccessToken(token: string): Promise<boolean> {
|
|
163
|
+
try {
|
|
164
|
+
await this.validateToken(token);
|
|
165
|
+
return true;
|
|
166
|
+
} catch (_) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Validate token
|
|
173
|
+
*
|
|
174
|
+
* @param {string} token The token to be validated
|
|
175
|
+
* @return {Promise<T>} Returns the payload of the token
|
|
176
|
+
*/
|
|
177
|
+
private async validateToken<T>(token: string): Promise<T> {
|
|
152
178
|
await this.coreClient.getJwks();
|
|
153
|
-
const
|
|
179
|
+
const jwks = jose.createLocalJWKSet({
|
|
154
180
|
keys: this.coreClient.keys
|
|
155
181
|
})
|
|
156
182
|
try {
|
|
157
|
-
await jose.jwtVerify(token,
|
|
158
|
-
return
|
|
159
|
-
} catch (
|
|
160
|
-
|
|
183
|
+
const { payload } = await jose.jwtVerify<T>(token, jwks);
|
|
184
|
+
return payload;
|
|
185
|
+
} catch (_) {
|
|
186
|
+
throw new Error("Invalid token");
|
|
161
187
|
}
|
|
162
188
|
}
|
|
163
189
|
}
|
package/src/types/auth.ts
CHANGED
|
@@ -62,4 +62,11 @@ export type TokenResponse = {
|
|
|
62
62
|
access_token: string;
|
|
63
63
|
id_token: string;
|
|
64
64
|
expires_in: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type IdpInitiatedLoginClaims ={
|
|
68
|
+
connection_id: string;
|
|
69
|
+
organization_id: string;
|
|
70
|
+
login_hint: string;
|
|
71
|
+
relay_state?: string;
|
|
65
72
|
}
|