Skip to content

Commit

Permalink
Merge branch 'main' into docs/improve-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-at-scalekit authored Aug 10, 2024
2 parents dfcdff1 + 6ef821b commit 7095deb
Show file tree
Hide file tree
Showing 36 changed files with 1,260 additions and 317 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ Initialize the Scalekit client using the appropriate credentials. Refer code sam
```javascript
import { ScalekitClient } from "@scalekit-sdk/node";

const sc = new ScalekitClient(
const scalekitClient = new ScalekitClient(
process.env.SCALEKIT_ENV_URL!,
process.env.SCALEKIT_CLIENT_ID!,
process.env.SCALEKIT_CLIENT_SECRET!
);

// Use the sc object to interact with the Scalekit API
const authUrl = sc.getAuthorizationUrl("https://acme-corp.com/redirect-uri", {
const authUrl = scalekitClient.getAuthorizationUrl("https://acme-corp.com/redirect-uri", {
state: "state",
connectionId: "connection_id",
});
Expand Down Expand Up @@ -102,10 +102,36 @@ app.get("/auth/login", (req, res) => {

// Handle the callback from Scalekit
app.get("/auth/callback", async (req, res) => {
const code = req.query.code as string;
const authResp = await sc.authenticateWithCode(code, redirectUri);
const { code, error, error_description, idp_initiated_login } = req.query;
// Handle error
if (error) {
return res.status(400).json({ error, error_description });
}
// Handle IdP initiated login
if (idp_initiated_login) {
// Get the claims from the IdP initiated login
const {
connection_id,
organization_id,
login_hint,
relay_state
} = await scalekitClient.getIdpInitiatedLoginClaims(idp_initiated_login as string);
// Get the authorization URL and redirect the user to the IdP login page
const url = scalekitClient.getAuthorizationUrl(
redirectUri,
{
connectionId: connection_id,
organizationId: organization_id,
loginHint: login_hint,
...(relay_state && { state: relay_state }),
}
)

return res.redirect(url);
}
const authResp = await scalekitClient.authenticateWithCode(code, redirectUri);
res.cookie("access_token", authResp.accessToken);
res.json(authResp.accessToken);
return res.json(authResp.accessToken);
});

app.listen(3000, () => {
Expand Down
25 changes: 5 additions & 20 deletions lib/connection.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/connection.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/pkg/grpc/scalekit/v1/commons/commons_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 64 additions & 1 deletion lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { CreateConnectionRequest, CreateConnectionResponse, DeleteConnectionRequest, GetConnectionRequest, GetConnectionResponse, ListConnectionsRequest, ListConnectionsResponse, ToggleConnectionRequest, ToggleConnectionResponse, UpdateConnectionRequest, UpdateConnectionResponse } from "./connections_pb.js";
import { CreateConnectionRequest, CreateConnectionResponse, CreateEnvironmentConnectionRequest, DeleteConnectionRequest, DeleteEnvironmentConnectionRequest, GetConnectionRequest, GetConnectionResponse, GetEnvironmentConnectionRequest, GetProvidersRequest, GetProvidersResponse, ListConnectionsRequest, ListConnectionsResponse, ToggleConnectionRequest, ToggleConnectionResponse, ToggleEnvironmentConnectionRequest, UpdateConnectionRequest, UpdateConnectionResponse, UpdateEnvironmentConnectionRequest } from "./connections_pb.js";
import { Empty, MethodKind } from "@bufbuild/protobuf";
/**
* @generated from service scalekit.v1.connections.ConnectionService
*/
export declare const ConnectionService: {
readonly typeName: "scalekit.v1.connections.ConnectionService";
readonly methods: {
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.GetProviders
*/
readonly getProviders: {
readonly name: "GetProviders";
readonly I: typeof GetProvidersRequest;
readonly O: typeof GetProvidersResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.CreateEnvironmentConnection
*/
readonly createEnvironmentConnection: {
readonly name: "CreateEnvironmentConnection";
readonly I: typeof CreateEnvironmentConnectionRequest;
readonly O: typeof CreateConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.CreateConnection
*/
Expand All @@ -15,6 +33,15 @@ export declare const ConnectionService: {
readonly O: typeof CreateConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.GetEnvironmentConnection
*/
readonly getEnvironmentConnection: {
readonly name: "GetEnvironmentConnection";
readonly I: typeof GetEnvironmentConnectionRequest;
readonly O: typeof GetConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.GetConnection
*/
Expand All @@ -33,6 +60,15 @@ export declare const ConnectionService: {
readonly O: typeof ListConnectionsResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.UpdateEnvironmentConnection
*/
readonly updateEnvironmentConnection: {
readonly name: "UpdateEnvironmentConnection";
readonly I: typeof UpdateEnvironmentConnectionRequest;
readonly O: typeof UpdateConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.UpdateConnection
*/
Expand All @@ -42,6 +78,15 @@ export declare const ConnectionService: {
readonly O: typeof UpdateConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.DeleteEnvironmentConnection
*/
readonly deleteEnvironmentConnection: {
readonly name: "DeleteEnvironmentConnection";
readonly I: typeof DeleteEnvironmentConnectionRequest;
readonly O: typeof Empty;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.DeleteConnection
*/
Expand All @@ -51,6 +96,15 @@ export declare const ConnectionService: {
readonly O: typeof Empty;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.EnableEnvironmentConnection
*/
readonly enableEnvironmentConnection: {
readonly name: "EnableEnvironmentConnection";
readonly I: typeof ToggleEnvironmentConnectionRequest;
readonly O: typeof ToggleConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.EnableConnection
*/
Expand All @@ -60,6 +114,15 @@ export declare const ConnectionService: {
readonly O: typeof ToggleConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.DisableEnvironmentConnection
*/
readonly disableEnvironmentConnection: {
readonly name: "DisableEnvironmentConnection";
readonly I: typeof ToggleEnvironmentConnectionRequest;
readonly O: typeof ToggleConnectionResponse;
readonly kind: MethodKind.Unary;
};
/**
* @generated from rpc scalekit.v1.connections.ConnectionService.DisableConnection
*/
Expand Down
63 changes: 63 additions & 0 deletions lib/pkg/grpc/scalekit/v1/connections/connections_connect.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7095deb

Please sign in to comment.