From 38c19444664c19da3c9fb1f169ec9e029e100795 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Tue, 2 Jul 2024 11:31:22 +0800 Subject: [PATCH 1/2] refactor: upgrade logto sdks --- packages/console/package.json | 2 +- packages/demo-app/package.json | 2 +- packages/integration-tests/package.json | 2 +- pnpm-lock.yaml | 52 +++++++++++-------------- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/packages/console/package.json b/packages/console/package.json index 03a3210bbc3..6cd55098e93 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -33,7 +33,7 @@ "@logto/language-kit": "workspace:^1.1.0", "@logto/phrases": "workspace:^1.11.0", "@logto/phrases-experience": "workspace:^1.6.1", - "@logto/react": "^3.0.11", + "@logto/react": "^3.0.12", "@logto/schemas": "workspace:^1.17.0", "@logto/shared": "workspace:^3.1.1", "@mdx-js/mdx": "^3.0.1", diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index ff0551ec4c1..f7784d97057 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -22,7 +22,7 @@ "@logto/core-kit": "workspace:^2.4.0", "@logto/language-kit": "workspace:^1.1.0", "@logto/phrases": "workspace:^1.10.0", - "@logto/react": "^3.0.11", + "@logto/react": "^3.0.12", "@logto/schemas": "workspace:^1.15.0", "@parcel/core": "2.9.3", "@parcel/transformer-sass": "2.9.3", diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 1b9a39e7804..7e88a68503f 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -26,7 +26,7 @@ "@jest/types": "^29.1.2", "@logto/connector-kit": "workspace:^3.0.0", "@logto/core-kit": "workspace:^", - "@logto/js": "^4.1.1", + "@logto/js": "^4.1.4", "@logto/node": "^2.4.7", "@logto/schemas": "workspace:^1.17.0", "@logto/shared": "workspace:^3.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0b88df5959..9a1b212c2d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2876,8 +2876,8 @@ importers: specifier: workspace:^1.6.1 version: link:../phrases-experience '@logto/react': - specifier: ^3.0.11 - version: 3.0.11(react@18.2.0) + specifier: ^3.0.12 + version: 3.0.13(react@18.2.0) '@logto/schemas': specifier: workspace:^1.17.0 version: link:../schemas @@ -3471,8 +3471,8 @@ importers: specifier: workspace:^1.10.0 version: link:../phrases '@logto/react': - specifier: ^3.0.11 - version: 3.0.11(react@18.2.0) + specifier: ^3.0.12 + version: 3.0.13(react@18.2.0) '@logto/schemas': specifier: workspace:^1.15.0 version: link:../schemas @@ -3787,8 +3787,8 @@ importers: specifier: workspace:^ version: link:../toolkit/core-kit '@logto/js': - specifier: ^4.1.1 - version: 4.1.1 + specifier: ^4.1.4 + version: 4.1.4 '@logto/node': specifier: ^2.4.7 version: 2.4.7 @@ -5245,30 +5245,27 @@ packages: resolution: {integrity: sha512-yDWSZMI2Qo/xoYU92tnwSP/gnSvq8+CLK5DqD/4brO42QJa7xjt7eA+HSyuMmSUrKffY2nP3riU81gs+nR8DkA==} engines: {node: ^18.12.0} - '@logto/browser@2.2.13': - resolution: {integrity: sha512-7fyenm6f2xSzZc8GHFpAL38rxAXf1hQH/ySSow8QHjgypF0pz9zy9bRSG1oVFgsMrFWYf73dPk7V2ACQ5Tujww==} + '@logto/browser@2.2.15': + resolution: {integrity: sha512-sQf2jYTHMuU8tVqkgaoWrKy3mhuyuLqsUDmDr6TBRv6jjFQMnniI6/5jHlqnllCs6B5x8qsjctcqcYiqKQmc5g==} '@logto/client@2.6.6': resolution: {integrity: sha512-QT7jMnzEIWHBNrf9/M8p1OErRBbbNZjoekXGji5aZCyUh975hh8+GEBL21HV71FT3H/5Cq4Gf1GzUbAIW3izMA==} - '@logto/client@2.7.0': - resolution: {integrity: sha512-8mj+757befwQJ4M0h4f3fQwUB1lruDkyLNTyRFOQxFfDMN1QeD70B4nMnz6iTX/Gi09HnIskmj9MHWrbvH6LSQ==} + '@logto/client@2.7.2': + resolution: {integrity: sha512-jsmuDl9QpXfR3uLEMPE67tvYoL5XcjJi+4yGqucYPjd4GH6SUHp3N9skk8C/OyygnKDPLY+ttwD0LaIbpGvn+Q==} '@logto/cloud@0.2.5-a7eedce': resolution: {integrity: sha512-FFjkGjqUgn9PCZnSuCODm2FcjqBm4JfPxfHCiXlOkUjeUhTJLrj7C0gjKzSQ/B6IaWri4EXN/meuqi5z/AMIPg==} engines: {node: ^20.9.0} - '@logto/js@4.1.1': - resolution: {integrity: sha512-+RgthBvDw30UojirtAjZeHNfOwDQVURmpjcIBYTIf6afx5F5jJq8b1D/eaFbrCFrmXmatkT2iN7X8kYHui86WQ==} - - '@logto/js@4.1.3': - resolution: {integrity: sha512-TIYrVSyD0c1mEt3fU9NKbWRTblujs3Ct/DYgNzBLzE/tmSVvwM6Z4JxnwZZ3xyfnL8dC4UfSQRlc2gjSMzKUGw==} + '@logto/js@4.1.4': + resolution: {integrity: sha512-6twud1nFBQmj89/aflzej6yD1QwXfPiYmRtyYuN4a7O9OaaW3X/kJBVwjKUn5NC9IUt+rd+jXsI3QJXENfaLAw==} '@logto/node@2.4.7': resolution: {integrity: sha512-AlANeqY1NIt93EBcRzrTmyAVHXOHpszTJK+qe1ok50rmZlTmX2p7yQvrg0/Ehwf/+4Rla5vooAR+HIFMaOmPpQ==} - '@logto/react@3.0.11': - resolution: {integrity: sha512-JyOOf7zZOEg7fTRldfi9SGwwbuk3qJTlIKld+GQ1yGWIXilI2JyyY2XQraZWpHQLW8KtQFgRWQ/fUKV0bideFQ==} + '@logto/react@3.0.13': + resolution: {integrity: sha512-t3aHYtgJLocawGtL5hVO05/At6qa5WUAxqTj7FhxI4BDpewD2KZCVfbQyr9YXrPg60mTzkk0r00oEEO3oZqSVA==} peerDependencies: react: '>=16.8.0' @@ -14960,22 +14957,22 @@ snapshots: '@silverhand/essentials': 2.9.1 tiny-cookie: 2.4.1 - '@logto/browser@2.2.13': + '@logto/browser@2.2.15': dependencies: - '@logto/client': 2.7.0 + '@logto/client': 2.7.2 '@silverhand/essentials': 2.9.1 js-base64: 3.7.5 '@logto/client@2.6.6': dependencies: - '@logto/js': 4.1.1 + '@logto/js': 4.1.4 '@silverhand/essentials': 2.9.1 camelcase-keys: 7.0.2 jose: 5.2.4 - '@logto/client@2.7.0': + '@logto/client@2.7.2': dependencies: - '@logto/js': 4.1.3 + '@logto/js': 4.1.4 '@silverhand/essentials': 2.9.1 camelcase-keys: 7.0.2 jose: 5.2.4 @@ -14987,12 +14984,7 @@ snapshots: transitivePeerDependencies: - zod - '@logto/js@4.1.1': - dependencies: - '@silverhand/essentials': 2.9.1 - camelcase-keys: 7.0.2 - - '@logto/js@4.1.3': + '@logto/js@4.1.4': dependencies: '@silverhand/essentials': 2.9.1 camelcase-keys: 7.0.2 @@ -15003,9 +14995,9 @@ snapshots: '@silverhand/essentials': 2.9.1 js-base64: 3.7.5 - '@logto/react@3.0.11(react@18.2.0)': + '@logto/react@3.0.13(react@18.2.0)': dependencies: - '@logto/browser': 2.2.13 + '@logto/browser': 2.2.15 '@silverhand/essentials': 2.9.1 react: 18.2.0 From 3b4e59195b145d28caa085d56ef952f55cf95896 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Tue, 2 Jul 2024 12:13:15 +0800 Subject: [PATCH 2/2] refactor: fix tests --- .../tests/api/oidc/organization-token.test.ts | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/integration-tests/src/tests/api/oidc/organization-token.test.ts b/packages/integration-tests/src/tests/api/oidc/organization-token.test.ts index 6bf9a433e2b..23f832a8084 100644 --- a/packages/integration-tests/src/tests/api/oidc/organization-token.test.ts +++ b/packages/integration-tests/src/tests/api/oidc/organization-token.test.ts @@ -1,4 +1,7 @@ +import assert from 'node:assert'; + import { UserScope, buildOrganizationUrn } from '@logto/core-kit'; +import { LogtoError } from '@logto/js'; import { InteractionEvent, MfaFactor } from '@logto/schemas'; import { createUserMfaVerification, deleteUser } from '#src/api/admin-user.js'; @@ -92,18 +95,33 @@ describe('get access token for organization', () => { await organizationApi.deleteUser(newOrganization.id, testUserId); await client.clearAccessToken(); - await expect( - client.getOrganizationTokenClaims(newOrganization.id) - ).rejects.toMatchInlineSnapshot('[Error: Access denied.]'); + + const error = await client + .getOrganizationTokenClaims(newOrganization.id) + .catch((error: unknown) => error); + + assert(error instanceof LogtoError); + expect(error.code).toBe('unexpected_response_error'); + expect(error.data).toMatchObject({ + code: 'oidc.access_denied', + error: 'access_denied', + }); }); it('should throw when organization requires mfa but user has not configured', async () => { await organizationApi.update(testOrganizationId, { isMfaRequired: true }); await client.clearAccessToken(); - await expect( - client.getOrganizationTokenClaims(testOrganizationId) - ).rejects.toMatchInlineSnapshot('[Error: Access denied.]'); + const error = await client + .getOrganizationTokenClaims(testOrganizationId) + .catch((error: unknown) => error); + + assert(error instanceof LogtoError); + expect(error.code).toBe('unexpected_response_error'); + expect(error.data).toMatchObject({ + code: 'oidc.access_denied', + error: 'access_denied', + }); }); it('should be able to get access token for organization when user has mfa configured', async () => {