-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser): add LogtoClient constructor (#160)
- Loading branch information
Showing
6 changed files
with
57 additions
and
8 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
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,8 @@ | ||
// Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom | ||
// https://github.com/jsdom/jsdom/issues/1612 | ||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
/* eslint-disable unicorn/prefer-module */ | ||
const { TextDecoder, TextEncoder } = require('text-encoder'); | ||
|
||
global.TextDecoder = TextDecoder; | ||
global.TextEncoder = TextEncoder; |
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import { TODO } from './index'; | ||
import { createRequester } from '@logto/js'; | ||
|
||
describe('TODO', () => { | ||
test('TODO', () => { | ||
const todo: TODO = 'TODO'; | ||
expect(todo).toEqual('TODO'); | ||
import LogtoClient from './index'; | ||
|
||
describe('LogtoClient', () => { | ||
test('constructor', () => { | ||
expect( | ||
() => | ||
new LogtoClient({ | ||
endpoint: 'https://logto.dev', | ||
clientId: 'client_id_value', | ||
usingPersistStorage: false, | ||
requester: createRequester(), | ||
}) | ||
).not.toThrow(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1 +1,28 @@ | ||
export type TODO = 'TODO'; | ||
import { OidcConfigResponse, Requester } from '@logto/js'; | ||
|
||
export type LogtoConfig = { | ||
endpoint: string; | ||
clientId: string; | ||
scopes?: string[]; | ||
resources?: string[]; | ||
usingPersistStorage?: boolean; | ||
requester: Requester; | ||
}; | ||
|
||
export type AccessToken = { | ||
token: string; | ||
scope: string; | ||
expiresAt: number; // Unix Timestamp in seconds | ||
}; | ||
|
||
export default class LogtoClient { | ||
protected accessTokenMap = new Map<string, AccessToken>(); | ||
protected refreshToken?: string; | ||
protected idToken?: string; | ||
protected logtoConfig: LogtoConfig; | ||
protected oidcConfig?: OidcConfigResponse; | ||
|
||
constructor(logtoConfig: LogtoConfig) { | ||
this.logtoConfig = logtoConfig; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.