Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"chokidar-cli": "^3.0.0",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.3.0",
"freestyle-sandboxes": "^0.1.5",
"jose": "^5.2.2",
"freestyle-sandboxes": "^0.1.6",
"jose": "^6.1.3",
"json-diff": "^1.0.6",
"next": "16.1.1",
"nodemailer": "^6.9.10",
Expand All @@ -102,7 +102,7 @@
"svix": "^1.25.0",
"vite": "^6.1.0",
"yaml": "^2.4.5",
"yup": "^1.4.0",
"yup": "^1.7.1",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions apps/backend/src/lib/js-execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ function createFreestyleEngine(): JsEngine {

const response = await freestyle.serverless.runs.create({
code,
config: {
nodeModules: options.nodeModules ?? {},
},
nodeModules: options.nodeModules ?? {},
});

if (response.result === undefined) {
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"export-to-csv": "^1.4.0",
"geist": "^1",
"input-otp": "^1.4.1",
"jose": "^5.2.2",
"jose": "^6.1.3",
"lodash": "^4.17.21",
"next": "16.1.1",
"next-themes": "^0.2.1",
Expand All @@ -99,7 +99,7 @@
"tailwindcss-animate": "^1.0.7",
"three": "^0.169.0",
"use-debounce": "^10.0.5",
"yup": "^1.4.0"
"yup": "^1.7.1"
},
"devDependencies": {
"@types/canvas-confetti": "^1.6.4",
Expand Down
3 changes: 2 additions & 1 deletion docker/dependencies/freestyle-mock/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ serve({
port: 8080,
async fetch(req) {
const url = new URL(req.url);
if (!(req.method === "POST" && url.pathname === "/execute/v1/script")) {
const isValidEndpoint = req.method === "POST" && (url.pathname === "/execute/v1/script" || url.pathname === "/execute/v2/script");
if (!isValidEndpoint) {
return new Response("Not found", { status: 404 });
}

Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"fumadocs-openapi": "^8.1.12",
"fumadocs-typescript": "^4.0.5",
"fumadocs-ui": "15.3.3",
"jose": "^6.1.0",
"jose": "^6.1.3",
"js-yaml": "^4.1.0",
"lucide-react": "^0.511.0",
"mermaid": "^11.6.0",
Expand Down
20 changes: 10 additions & 10 deletions packages/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@
"LICENSE"
],
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@simplewebauthn/browser": "^11.0.0",
"@hookform/resolvers": "^5.2.2",
"@simplewebauthn/browser": "^13.2.2",
"@stackframe/stack-shared": "workspace:*",
"@tanstack/react-table": "^8.20.5",
"color": "^4.2.3",
"cookie": "^0.6.0",
"jose": "^5.2.2",
"@tanstack/react-table": "^8.21.3",
"color": "^5.0.3",
"cookie": "^1.1.1",
Comment thread
nams1570 marked this conversation as resolved.
"jose": "^6.1.3",
"js-cookie": "^3.0.5",
"oauth4webapi": "^2.10.3",
"oauth4webapi": "^3.8.3",
"@oslojs/otp": "^1.1.0",
"qrcode": "^1.5.4",
"rimraf": "^5.0.5",
"tsx": "^4.7.2",
"yup": "^1.4.0"
"rimraf": "^6.1.2",
"tsx": "^4.21.0",
"yup": "^1.7.1"
},
"devDependencies": {
"@quetzallabs/i18n": "^0.1.19",
Expand Down
24 changes: 12 additions & 12 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@
"LICENSE"
],
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@hookform/resolvers": "^5.2.2",
"@stripe/react-stripe-js": "^3.8.1",
"@stripe/stripe-js": "^7.7.0",
"@simplewebauthn/browser": "^11.0.0",
"@simplewebauthn/browser": "^13.2.2",
"@stackframe/stack-shared": "workspace:*",
"@stackframe/stack-ui": "workspace:*",
"@tanstack/react-table": "^8.20.5",
"@tanstack/react-table": "^8.21.3",
"browser-image-compression": "^2.0.2",
"color": "^4.2.3",
"cookie": "^0.6.0",
"jose": "^5.2.2",
"color": "^5.0.3",
"cookie": "^1.1.1",
"jose": "^6.1.3",
"js-cookie": "^3.0.5",
"lucide-react": "^0.378.0",
"oauth4webapi": "^2.10.3",
"oauth4webapi": "^3.8.3",
"@oslojs/otp": "^1.1.0",
"qrcode": "^1.5.4",
"react-easy-crop": "^5.4.1",
"react-hook-form": "^7.51.4",
"rimraf": "^5.0.5",
"react-easy-crop": "^5.5.6",
"react-hook-form": "^7.70.0",
"rimraf": "^6.1.2",
"tailwindcss-animate": "^1.0.7",
"tsx": "^4.7.2",
"yup": "^1.4.0"
"tsx": "^4.21.0",
"yup": "^1.7.1"
},
"peerDependencies": {
"@types/react": ">=18.3.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/stack-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/react-dom": ">=19.0.0",
"react": ">=19.0.0",
"react-dom": ">=19.0.0",
"yup": "^1.4.0"
"yup": "^1.7.1"
},
"peerDependenciesMeta": {
"react": {
Expand All @@ -64,8 +64,8 @@
"elliptic": "^6.5.7",
"esbuild-wasm": "^0.20.2",
"ip-regex": "^5.0.0",
"jose": "^5.2.2",
"oauth4webapi": "^2.10.3",
"jose": "^6.1.3",
"oauth4webapi": "^3.8.3",
"semver": "^7.6.3",
"uuid": "^9.0.1"
},
Expand Down
76 changes: 57 additions & 19 deletions packages/stack-shared/src/interface/client-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { KnownError, KnownErrors } from '../known-errors';
import { inlineProductSchema } from '../schema-fields';
import { AccessToken, InternalSession, RefreshToken } from '../sessions';
import { generateSecureRandomString } from '../utils/crypto';
import { getNodeEnvironment } from '../utils/env';
import { StackAssertionError, throwErr } from '../utils/errors';
import { globalVar } from '../utils/globals';
import { HTTP_METHODS, HttpMethod } from '../utils/http';
Expand Down Expand Up @@ -153,22 +154,27 @@ export class StackClientInterface {
throw new Error("Admin session token is currently not supported for fetching new access token. Did you try to log in on a StackApp initiated with the admin session?");
}

const tokenEndpoint = this.getApiUrl() + '/auth/oauth/token';
const as = {
issuer: this.options.getBaseUrl(),
algorithm: 'oauth2',
token_endpoint: this.getApiUrl() + '/auth/oauth/token',
token_endpoint: tokenEndpoint,
};
const client: oauth.Client = {
client_id: this.projectId,
client_secret: this.options.publishableClientKey,
token_endpoint_auth_method: 'client_secret_post',
};

const clientAuthentication = oauth.ClientSecretPost(this.options.publishableClientKey);
Comment thread
nams1570 marked this conversation as resolved.
const allowInsecure = getNodeEnvironment() === 'test' && tokenEndpoint.startsWith('http://');

const response = await this._networkRetryException(async () => {
const rawResponse = await oauth.refreshTokenGrantRequest(
as,
client,
clientAuthentication,
refreshToken.token,
allowInsecure ? { [oauth.allowInsecureRequests]: true } : undefined,
);

const response = await this._processResponse(rawResponse);
Expand All @@ -190,17 +196,26 @@ export class StackClientInterface {
});
if (!response) return null;

const result = await oauth.processRefreshTokenResponse(as, client, response);
if (oauth.isOAuth2Error(result)) {
// TODO Handle OAuth 2.0 response body error
throw new StackAssertionError("OAuth error", { result });
let result: oauth.TokenEndpointResponse;
try {
result = await oauth.processRefreshTokenResponse(as, client, response);
} catch (e){
if (e instanceof oauth.ResponseBodyError) {
throw new StackAssertionError("ResponseBodyError when processing refresh token response", {
cause: e.cause,
code: e.code,
error: e.error,
});
}
throw new StackAssertionError("Unexpected error when processing refresh token response", { cause: e });
}
Comment thread
nams1570 marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (!result.access_token) {
throw new StackAssertionError("Access token not found in token endpoint response, this is weird!");
}

return AccessToken.createIfValid(result.access_token) ?? throwErr("Access token in fetchNewAccessToken is invalid, looks like the backend is returning an invalid token!", { result });

}

public async sendClientRequest(
Expand Down Expand Up @@ -1015,37 +1030,60 @@ export class StackClientInterface {
// TODO fix
throw new Error("Admin session token is currently not supported for OAuth");
}
const tokenEndpoint = this.getApiUrl() + '/auth/oauth/token';
const as = {
issuer: this.options.getBaseUrl(),
algorithm: 'oauth2',
token_endpoint: this.getApiUrl() + '/auth/oauth/token',
token_endpoint: tokenEndpoint,
};
const client: oauth.Client = {
client_id: this.projectId,
client_secret: this.options.publishableClientKey,
token_endpoint_auth_method: 'client_secret_post',
};
const params = await this._networkRetryException(
async () => oauth.validateAuthResponse(as, client, options.oauthParams, options.state),
);
if (oauth.isOAuth2Error(params)) {
throw new StackAssertionError("Error validating outer OAuth response", { params }); // Handle OAuth 2.0 redirect error
const clientAuthentication = oauth.ClientSecretPost(this.options.publishableClientKey);
// Allow insecure HTTP requests only in test environment (for localhost testing)
const allowInsecure = getNodeEnvironment() === 'test' && tokenEndpoint.startsWith('http://');
Comment thread
nams1570 marked this conversation as resolved.

let params: URLSearchParams;
try {
params = oauth.validateAuthResponse(as, client, options.oauthParams, options.state);
} catch (e) {
if (e instanceof oauth.AuthorizationResponseError) {
throw new StackAssertionError("Authorization response error when validating outer OAuth response", {
//cause is a URLSearchParams object for this error, so we need to serialize it better
cause: Object.fromEntries(e.cause),
code: e.code,
error: e.error,
});
}
throw new StackAssertionError("Unexpected error when validating outer OAuth response", { cause: e });
}
Comment thread
nams1570 marked this conversation as resolved.
Comment thread
nams1570 marked this conversation as resolved.
const response = await oauth.authorizationCodeGrantRequest(
as,
client,
clientAuthentication,
params,
options.redirectUri,
options.codeVerifier,
allowInsecure ? { [oauth.allowInsecureRequests]: true } : undefined,
);

const result = await oauth.processAuthorizationCodeOAuth2Response(as, client, response);
if (oauth.isOAuth2Error(result)) {
if ("code" in result && result.code === "MULTI_FACTOR_AUTHENTICATION_REQUIRED") {
throw new KnownErrors.MultiFactorAuthenticationRequired((result as any).details.attempt_code);
let result;
try {
result = await oauth.processAuthorizationCodeResponse(as, client, response);
} catch (e) {
if (e instanceof oauth.ResponseBodyError) {
if ((e.cause as any).code === "MULTI_FACTOR_AUTHENTICATION_REQUIRED") {
throw new KnownErrors.MultiFactorAuthenticationRequired((e.cause as any).details.attempt_code);
}
// TODO Handle OAuth 2.0 response body error
throw new StackAssertionError("Outer OAuth error during authorization code response", {
cause: e.cause,
code: e.code,
error: e.error,
});
}
Comment thread
nams1570 marked this conversation as resolved.
// TODO Handle OAuth 2.0 response body error
throw new StackAssertionError("Outer OAuth error during authorization code response", { result });
throw new StackAssertionError("Unexpected error when processing authorization code response", { cause: e });
Comment thread
nams1570 marked this conversation as resolved.
}
return {
newUser: result.is_new_user as boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/stack-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/react-dom": ">=19.0.0",
"react": ">=19.0.0",
"react-dom": ">=19.0.0",
"yup": "^1.4.0"
"yup": "^1.7.1"
},
"peerDependenciesMeta": {
"@types/react": {
Expand Down
24 changes: 12 additions & 12 deletions packages/stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,29 @@
"LICENSE"
],
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@hookform/resolvers": "^5.2.2",
"@stripe/react-stripe-js": "^3.8.1",
"@stripe/stripe-js": "^7.7.0",
"@simplewebauthn/browser": "^11.0.0",
"@simplewebauthn/browser": "^13.2.2",
"@stackframe/stack-sc": "workspace:*",
"@stackframe/stack-shared": "workspace:*",
"@stackframe/stack-ui": "workspace:*",
"@tanstack/react-table": "^8.20.5",
"@tanstack/react-table": "^8.21.3",
"browser-image-compression": "^2.0.2",
"color": "^4.2.3",
"cookie": "^0.6.0",
"jose": "^5.2.2",
"color": "^5.0.3",
"cookie": "^1.1.1",
"jose": "^6.1.3",
"js-cookie": "^3.0.5",
"lucide-react": "^0.378.0",
"oauth4webapi": "^2.10.3",
"oauth4webapi": "^3.8.3",
"@oslojs/otp": "^1.1.0",
"qrcode": "^1.5.4",
"react-easy-crop": "^5.4.1",
"react-hook-form": "^7.51.4",
"rimraf": "^5.0.5",
"react-easy-crop": "^5.5.6",
"react-hook-form": "^7.70.0",
"rimraf": "^6.1.2",
"tailwindcss-animate": "^1.0.7",
"tsx": "^4.7.2",
"yup": "^1.4.0"
"tsx": "^4.21.0",
"yup": "^1.7.1"
},
"peerDependencies": {
"@types/react": ">=18.3.0",
Expand Down
Loading