-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6030 from logto-io/gao-google-one-tap-connector
feat(connector): google one tap
- Loading branch information
Showing
11 changed files
with
325 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@logto/connector-kit": major | ||
--- | ||
|
||
remove `.catchall()` for `connectorMetadataGuard` | ||
|
||
`.catchall()` allows unknown keys to be parsed as metadata. This is troublesome when we want to strip out unknown keys (Zod provides `.strip()` for this purpose but somehow it doesn't work with `.catchall()`). | ||
|
||
For data extensibility, we added `customData` field to `ConnectorMetadata` type to store unknown keys. For example, the `fromEmail` field in `connector-logto-email` is not part of the standard metadata, so it should be stored in `customData` in the future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@logto/connector-google": minor | ||
"@logto/connector-kit": minor | ||
--- | ||
|
||
support Google One Tap | ||
|
||
- support parsing and validating Google One Tap data in `connector-google` | ||
- add Google connector constants in `connector-kit` for reuse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,25 @@ import { mockedConfig } from './mock.js'; | |
|
||
const getConfig = vi.fn().mockResolvedValue(mockedConfig); | ||
|
||
vi.mock('jose', () => ({ | ||
createRemoteJWKSet: vi.fn().mockReturnValue({ | ||
getSigningKey: vi.fn().mockResolvedValue({ | ||
publicKey: 'publicKey', | ||
}), | ||
}), | ||
jwtVerify: vi.fn().mockResolvedValue({ | ||
payload: { | ||
sub: '1234567890', | ||
name: 'John Wick', | ||
given_name: 'John', | ||
family_name: 'Wick', | ||
email: '[email protected]', | ||
email_verified: true, | ||
picture: 'https://example.com/image.jpg', | ||
}, | ||
}), | ||
})); | ||
|
||
describe('google connector', () => { | ||
describe('getAuthorizationUri', () => { | ||
afterEach(() => { | ||
|
@@ -105,6 +124,31 @@ describe('google connector', () => { | |
}); | ||
}); | ||
|
||
it('should be able to decode ID token from Google One Tap', async () => { | ||
const connector = await createConnector({ getConfig }); | ||
const socialUserInfo = await connector.getUserInfo( | ||
{ | ||
credential: 'credential', | ||
}, | ||
vi.fn() | ||
); | ||
expect(socialUserInfo).toStrictEqual({ | ||
id: '1234567890', | ||
avatar: 'https://example.com/image.jpg', | ||
name: 'John Wick', | ||
email: '[email protected]', | ||
rawData: { | ||
sub: '1234567890', | ||
name: 'John Wick', | ||
given_name: 'John', | ||
family_name: 'Wick', | ||
email: '[email protected]', | ||
email_verified: true, | ||
picture: 'https://example.com/image.jpg', | ||
}, | ||
}); | ||
}); | ||
|
||
it('throws SocialAccessTokenInvalid error if remote response code is 401', async () => { | ||
nock(userInfoEndpoint).post('').reply(401); | ||
const connector = await createConnector({ getConfig }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.