@jbrowse/plugin-authentication 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/DropboxOAuthModel/configSchema.js +0 -1
  2. package/dist/DropboxOAuthModel/index.js +0 -1
  3. package/dist/DropboxOAuthModel/model.js +0 -1
  4. package/dist/DropboxOAuthModel/util.js +0 -1
  5. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +0 -1
  6. package/dist/ExternalTokenModel/configSchema.js +0 -1
  7. package/dist/ExternalTokenModel/index.js +0 -1
  8. package/dist/ExternalTokenModel/model.js +0 -1
  9. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +0 -1
  10. package/dist/GoogleDriveOAuthModel/configSchema.js +0 -1
  11. package/dist/GoogleDriveOAuthModel/index.js +0 -1
  12. package/dist/GoogleDriveOAuthModel/model.js +0 -1
  13. package/dist/GoogleDriveOAuthModel/util.js +0 -1
  14. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +0 -1
  15. package/dist/HTTPBasicModel/configSchema.js +0 -1
  16. package/dist/HTTPBasicModel/index.js +0 -1
  17. package/dist/HTTPBasicModel/model.js +0 -1
  18. package/dist/OAuthModel/configSchema.js +0 -1
  19. package/dist/OAuthModel/index.js +0 -1
  20. package/dist/OAuthModel/model.js +0 -1
  21. package/dist/OAuthModel/util.js +0 -1
  22. package/dist/index.js +0 -1
  23. package/dist/util.js +0 -1
  24. package/esm/DropboxOAuthModel/configSchema.js +0 -1
  25. package/esm/DropboxOAuthModel/index.js +0 -1
  26. package/esm/DropboxOAuthModel/model.js +0 -1
  27. package/esm/DropboxOAuthModel/util.js +0 -1
  28. package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +0 -1
  29. package/esm/ExternalTokenModel/configSchema.js +0 -1
  30. package/esm/ExternalTokenModel/index.js +0 -1
  31. package/esm/ExternalTokenModel/model.js +0 -1
  32. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +0 -1
  33. package/esm/GoogleDriveOAuthModel/configSchema.js +0 -1
  34. package/esm/GoogleDriveOAuthModel/index.js +0 -1
  35. package/esm/GoogleDriveOAuthModel/model.js +0 -1
  36. package/esm/GoogleDriveOAuthModel/util.js +0 -1
  37. package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +0 -1
  38. package/esm/HTTPBasicModel/configSchema.js +0 -1
  39. package/esm/HTTPBasicModel/index.js +0 -1
  40. package/esm/HTTPBasicModel/model.js +0 -1
  41. package/esm/OAuthModel/configSchema.js +0 -1
  42. package/esm/OAuthModel/index.js +0 -1
  43. package/esm/OAuthModel/model.js +0 -1
  44. package/esm/OAuthModel/util.js +0 -1
  45. package/esm/index.js +0 -1
  46. package/esm/util.js +0 -1
  47. package/package.json +3 -4
  48. package/dist/DropboxOAuthModel/configSchema.js.map +0 -1
  49. package/dist/DropboxOAuthModel/index.js.map +0 -1
  50. package/dist/DropboxOAuthModel/model.js.map +0 -1
  51. package/dist/DropboxOAuthModel/util.js.map +0 -1
  52. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js.map +0 -1
  53. package/dist/ExternalTokenModel/configSchema.js.map +0 -1
  54. package/dist/ExternalTokenModel/index.js.map +0 -1
  55. package/dist/ExternalTokenModel/model.js.map +0 -1
  56. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js.map +0 -1
  57. package/dist/GoogleDriveOAuthModel/configSchema.js.map +0 -1
  58. package/dist/GoogleDriveOAuthModel/index.js.map +0 -1
  59. package/dist/GoogleDriveOAuthModel/model.js.map +0 -1
  60. package/dist/GoogleDriveOAuthModel/util.js.map +0 -1
  61. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js.map +0 -1
  62. package/dist/HTTPBasicModel/configSchema.js.map +0 -1
  63. package/dist/HTTPBasicModel/index.js.map +0 -1
  64. package/dist/HTTPBasicModel/model.js.map +0 -1
  65. package/dist/OAuthModel/configSchema.js.map +0 -1
  66. package/dist/OAuthModel/index.js.map +0 -1
  67. package/dist/OAuthModel/model.js.map +0 -1
  68. package/dist/OAuthModel/util.js.map +0 -1
  69. package/dist/index.js.map +0 -1
  70. package/dist/util.js.map +0 -1
  71. package/esm/DropboxOAuthModel/configSchema.js.map +0 -1
  72. package/esm/DropboxOAuthModel/index.js.map +0 -1
  73. package/esm/DropboxOAuthModel/model.js.map +0 -1
  74. package/esm/DropboxOAuthModel/util.js.map +0 -1
  75. package/esm/ExternalTokenModel/ExternalTokenEntryForm.js.map +0 -1
  76. package/esm/ExternalTokenModel/configSchema.js.map +0 -1
  77. package/esm/ExternalTokenModel/index.js.map +0 -1
  78. package/esm/ExternalTokenModel/model.js.map +0 -1
  79. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js.map +0 -1
  80. package/esm/GoogleDriveOAuthModel/configSchema.js.map +0 -1
  81. package/esm/GoogleDriveOAuthModel/index.js.map +0 -1
  82. package/esm/GoogleDriveOAuthModel/model.js.map +0 -1
  83. package/esm/GoogleDriveOAuthModel/util.js.map +0 -1
  84. package/esm/HTTPBasicModel/HTTPBasicLoginForm.js.map +0 -1
  85. package/esm/HTTPBasicModel/configSchema.js.map +0 -1
  86. package/esm/HTTPBasicModel/index.js.map +0 -1
  87. package/esm/HTTPBasicModel/model.js.map +0 -1
  88. package/esm/OAuthModel/configSchema.js.map +0 -1
  89. package/esm/OAuthModel/index.js.map +0 -1
  90. package/esm/OAuthModel/model.js.map +0 -1
  91. package/esm/OAuthModel/util.js.map +0 -1
  92. package/esm/index.js.map +0 -1
  93. package/esm/util.js.map +0 -1
  94. package/src/DropboxOAuthModel/configSchema.ts +0 -69
  95. package/src/DropboxOAuthModel/index.ts +0 -2
  96. package/src/DropboxOAuthModel/model.tsx +0 -122
  97. package/src/DropboxOAuthModel/util.ts +0 -36
  98. package/src/ExternalTokenModel/ExternalTokenEntryForm.tsx +0 -55
  99. package/src/ExternalTokenModel/configSchema.ts +0 -36
  100. package/src/ExternalTokenModel/index.ts +0 -2
  101. package/src/ExternalTokenModel/model.tsx +0 -70
  102. package/src/GoogleDriveOAuthModel/GoogleDriveFilehandle.ts +0 -38
  103. package/src/GoogleDriveOAuthModel/configSchema.ts +0 -61
  104. package/src/GoogleDriveOAuthModel/index.ts +0 -2
  105. package/src/GoogleDriveOAuthModel/model.tsx +0 -124
  106. package/src/GoogleDriveOAuthModel/util.ts +0 -29
  107. package/src/HTTPBasicModel/HTTPBasicLoginForm.tsx +0 -68
  108. package/src/HTTPBasicModel/configSchema.ts +0 -43
  109. package/src/HTTPBasicModel/index.ts +0 -2
  110. package/src/HTTPBasicModel/model.tsx +0 -85
  111. package/src/OAuthModel/configSchema.ts +0 -91
  112. package/src/OAuthModel/index.ts +0 -2
  113. package/src/OAuthModel/model.tsx +0 -430
  114. package/src/OAuthModel/util.ts +0 -33
  115. package/src/__snapshots__/index.test.js.snap +0 -8
  116. package/src/index.test.js +0 -96
  117. package/src/index.ts +0 -108
  118. package/src/util.ts +0 -25
@@ -1,29 +0,0 @@
1
- import { getResponseError } from '../util'
2
-
3
- interface GoogleDriveError {
4
- error: {
5
- errors: {
6
- domain: string
7
- reason: string
8
- message: string
9
- locationType?: string
10
- location?: string
11
- }[]
12
- code: number
13
- message: string
14
- }
15
- }
16
-
17
- export async function getDescriptiveErrorMessage(
18
- response: Response,
19
- reason?: string,
20
- ) {
21
- let errorMessage = ''
22
- try {
23
- const err = JSON.parse(await response.text()) as GoogleDriveError
24
- errorMessage = err.error.message
25
- } catch (error) {
26
- /* do nothing */
27
- }
28
- return getResponseError({ response, reason, statusText: errorMessage })
29
- }
@@ -1,68 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { Button, DialogContent, DialogActions, TextField } from '@mui/material'
3
- import { Dialog } from '@jbrowse/core/ui'
4
-
5
- export const HTTPBasicLoginForm = ({
6
- internetAccountId,
7
- handleClose,
8
- }: {
9
- internetAccountId: string
10
- handleClose: (arg?: string) => void
11
- }) => {
12
- const [username, setUsername] = useState('')
13
- const [password, setPassword] = useState('')
14
-
15
- return (
16
- <Dialog
17
- open
18
- maxWidth="xl"
19
- data-testid="login-httpbasic"
20
- title={`Log In for ${internetAccountId}`}
21
- >
22
- <form
23
- onSubmit={event => {
24
- if (username && password) {
25
- handleClose(btoa(`${username}:${password}`))
26
- } else {
27
- handleClose()
28
- }
29
- event.preventDefault()
30
- }}
31
- >
32
- <DialogContent style={{ display: 'flex', flexDirection: 'column' }}>
33
- <TextField
34
- required
35
- label="Username"
36
- variant="outlined"
37
- inputProps={{ 'data-testid': 'login-httpbasic-username' }}
38
- onChange={event => setUsername(event.target.value)}
39
- margin="dense"
40
- />
41
- <TextField
42
- required
43
- label="Password"
44
- type="password"
45
- autoComplete="current-password"
46
- variant="outlined"
47
- inputProps={{ 'data-testid': 'login-httpbasic-password' }}
48
- onChange={event => setPassword(event.target.value)}
49
- margin="dense"
50
- />
51
- </DialogContent>
52
- <DialogActions>
53
- <Button variant="contained" color="primary" type="submit">
54
- Submit
55
- </Button>
56
- <Button
57
- variant="contained"
58
- color="secondary"
59
- type="submit"
60
- onClick={() => handleClose()}
61
- >
62
- Cancel
63
- </Button>
64
- </DialogActions>
65
- </form>
66
- </Dialog>
67
- )
68
- }
@@ -1,43 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- import { Instance } from 'mobx-state-tree'
3
- import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models'
4
-
5
- /**
6
- * #config HTTPBasicInternetAccount
7
- */
8
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
9
-
10
- const HTTPBasicConfigSchema = ConfigurationSchema(
11
- 'HTTPBasicInternetAccount',
12
- {
13
- /**
14
- * #slot
15
- */
16
- tokenType: {
17
- description: 'a custom name for a token to include in the header',
18
- type: 'string',
19
- defaultValue: 'Basic',
20
- },
21
- /**
22
- * #slot
23
- */
24
- validateWithHEAD: {
25
- description: 'validate the token with a HEAD request before using it',
26
- type: 'boolean',
27
- defaultValue: true,
28
- },
29
- },
30
- {
31
- /**
32
- * #baseConfiguration
33
- */
34
- baseConfiguration: BaseInternetAccountConfig,
35
- explicitlyTyped: true,
36
- },
37
- )
38
-
39
- export type HTTPBasicInternetAccountConfigModel = typeof HTTPBasicConfigSchema
40
-
41
- export type HTTPBasicInternetAccountConfig =
42
- Instance<HTTPBasicInternetAccountConfigModel>
43
- export default HTTPBasicConfigSchema
@@ -1,2 +0,0 @@
1
- export { default as configSchema } from './configSchema'
2
- export { default as modelFactory } from './model'
@@ -1,85 +0,0 @@
1
- import { ConfigurationReference, getConf } from '@jbrowse/core/configuration'
2
- import { InternetAccount } from '@jbrowse/core/pluggableElementTypes/models'
3
- import { UriLocation } from '@jbrowse/core/util/types'
4
- import { Instance, types, getRoot } from 'mobx-state-tree'
5
-
6
- // locals
7
- import { HTTPBasicInternetAccountConfigModel } from './configSchema'
8
- import { HTTPBasicLoginForm } from './HTTPBasicLoginForm'
9
- import { getResponseError } from '../util'
10
-
11
- /**
12
- * #stateModel HTTPBasicInternetAccount
13
- */
14
- const stateModelFactory = (
15
- configSchema: HTTPBasicInternetAccountConfigModel,
16
- ) => {
17
- return InternetAccount.named('HTTPBasicInternetAccount')
18
- .props({
19
- /**
20
- * #property
21
- */
22
- type: types.literal('HTTPBasicInternetAccount'),
23
- /**
24
- * #property
25
- */
26
- configuration: ConfigurationReference(configSchema),
27
- })
28
- .views(self => ({
29
- /**
30
- * #getter
31
- */
32
- get validateWithHEAD(): boolean {
33
- return getConf(self, 'validateWithHEAD')
34
- },
35
- }))
36
- .actions(self => ({
37
- /**
38
- * #action
39
- */
40
- getTokenFromUser(
41
- resolve: (token: string) => void,
42
- reject: (error: Error) => void,
43
- ) {
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- const { session } = getRoot<any>(self)
46
- session.queueDialog((doneCallback: () => void) => [
47
- HTTPBasicLoginForm,
48
- {
49
- internetAccountId: self.internetAccountId,
50
- handleClose: (token: string) => {
51
- if (token) {
52
- resolve(token)
53
- } else {
54
- reject(new Error('User cancelled entry'))
55
- }
56
- doneCallback()
57
- },
58
- },
59
- ])
60
- },
61
- /**
62
- * #action
63
- */
64
- async validateToken(token: string, location: UriLocation) {
65
- if (!self.validateWithHEAD) {
66
- return token
67
- }
68
- const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token)
69
- const response = await fetch(location.uri, newInit)
70
- if (!response.ok) {
71
- throw new Error(
72
- await getResponseError({
73
- response,
74
- reason: 'Error validating token',
75
- }),
76
- )
77
- }
78
- return token
79
- },
80
- }))
81
- }
82
-
83
- export default stateModelFactory
84
- export type HTTPBasicStateModel = ReturnType<typeof stateModelFactory>
85
- export type HTTPBasicModel = Instance<HTTPBasicStateModel>
@@ -1,91 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- import { Instance } from 'mobx-state-tree'
3
- import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models'
4
-
5
- /**
6
- * #config OAuthInternetAccount
7
- */
8
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
9
-
10
- const OAuthConfigSchema = ConfigurationSchema(
11
- 'OAuthInternetAccount',
12
- {
13
- /**
14
- * #slot
15
- */
16
- tokenType: {
17
- description: 'a custom name for a token to include in the header',
18
- type: 'string',
19
- defaultValue: 'Bearer',
20
- },
21
- /**
22
- * #slot
23
- */
24
- authEndpoint: {
25
- description: 'the authorization code endpoint of the internet account',
26
- type: 'string',
27
- defaultValue: '',
28
- },
29
- /**
30
- * #slot
31
- */
32
- tokenEndpoint: {
33
- description: 'the token endpoint of the internet account',
34
- type: 'string',
35
- defaultValue: '',
36
- },
37
- /**
38
- * #slot
39
- */
40
- needsPKCE: {
41
- description: 'boolean to indicate if the endpoint needs a PKCE code',
42
- type: 'boolean',
43
- defaultValue: false,
44
- },
45
- /**
46
- * #slot
47
- */
48
- clientId: {
49
- description: 'id for the OAuth application',
50
- type: 'string',
51
- defaultValue: '',
52
- },
53
- /**
54
- * #slot
55
- */
56
- scopes: {
57
- description: 'optional scopes for the authorization call',
58
- type: 'string',
59
- defaultValue: '',
60
- },
61
- /**
62
- * #slot
63
- */
64
- state: {
65
- description: 'optional state for the authorization call',
66
- type: 'string',
67
- defaultValue: '',
68
- },
69
- /**
70
- * #slot
71
- */
72
- responseType: {
73
- description:
74
- "the type of response from the authorization endpoint. can be 'token' or 'code'",
75
- type: 'string',
76
- defaultValue: 'code',
77
- },
78
- },
79
- {
80
- /**
81
- * #baseConfiguration
82
- */
83
- baseConfiguration: BaseInternetAccountConfig,
84
- explicitlyTyped: true,
85
- },
86
- )
87
-
88
- export type OAuthInternetAccountConfigModel = typeof OAuthConfigSchema
89
- export type OAuthInternetAccountConfig =
90
- Instance<OAuthInternetAccountConfigModel>
91
- export default OAuthConfigSchema
@@ -1,2 +0,0 @@
1
- export { default as configSchema } from './configSchema'
2
- export { default as modelFactory } from './model'