@jbrowse/plugin-authentication 2.2.0
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.
- package/LICENSE +201 -0
- package/dist/DropboxOAuthModel/configSchema.d.ts +5 -0
- package/dist/DropboxOAuthModel/configSchema.js +69 -0
- package/dist/DropboxOAuthModel/configSchema.js.map +1 -0
- package/dist/DropboxOAuthModel/index.d.ts +2 -0
- package/dist/DropboxOAuthModel/index.js +11 -0
- package/dist/DropboxOAuthModel/index.js.map +1 -0
- package/dist/DropboxOAuthModel/model.d.ts +98 -0
- package/dist/DropboxOAuthModel/model.js +103 -0
- package/dist/DropboxOAuthModel/model.js.map +1 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +5 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +59 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -0
- package/dist/ExternalTokenModel/configSchema.d.ts +5 -0
- package/dist/ExternalTokenModel/configSchema.js +26 -0
- package/dist/ExternalTokenModel/configSchema.js.map +1 -0
- package/dist/ExternalTokenModel/index.d.ts +2 -0
- package/dist/ExternalTokenModel/index.js +11 -0
- package/dist/ExternalTokenModel/index.js.map +1 -0
- package/dist/ExternalTokenModel/model.d.ts +67 -0
- package/dist/ExternalTokenModel/model.js +59 -0
- package/dist/ExternalTokenModel/model.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/configSchema.d.ts +5 -0
- package/dist/GoogleDriveOAuthModel/configSchema.js +53 -0
- package/dist/GoogleDriveOAuthModel/configSchema.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/index.d.ts +2 -0
- package/dist/GoogleDriveOAuthModel/index.js +11 -0
- package/dist/GoogleDriveOAuthModel/index.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/model.d.ts +111 -0
- package/dist/GoogleDriveOAuthModel/model.js +115 -0
- package/dist/GoogleDriveOAuthModel/model.js.map +1 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +5 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +55 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -0
- package/dist/HTTPBasicModel/configSchema.d.ts +5 -0
- package/dist/HTTPBasicModel/configSchema.js +34 -0
- package/dist/HTTPBasicModel/configSchema.js.map +1 -0
- package/dist/HTTPBasicModel/index.d.ts +2 -0
- package/dist/HTTPBasicModel/index.js +11 -0
- package/dist/HTTPBasicModel/index.js.map +1 -0
- package/dist/HTTPBasicModel/model.d.ts +67 -0
- package/dist/HTTPBasicModel/model.js +59 -0
- package/dist/HTTPBasicModel/model.js.map +1 -0
- package/dist/OAuthModel/configSchema.d.ts +5 -0
- package/dist/OAuthModel/configSchema.js +90 -0
- package/dist/OAuthModel/configSchema.js.map +1 -0
- package/dist/OAuthModel/index.d.ts +2 -0
- package/dist/OAuthModel/index.js +11 -0
- package/dist/OAuthModel/index.js.map +1 -0
- package/dist/OAuthModel/model.d.ts +91 -0
- package/dist/OAuthModel/model.js +317 -0
- package/dist/OAuthModel/model.js.map +1 -0
- package/dist/index.d.ts +399 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/esm/DropboxOAuthModel/configSchema.d.ts +5 -0
- package/esm/DropboxOAuthModel/configSchema.js +64 -0
- package/esm/DropboxOAuthModel/configSchema.js.map +1 -0
- package/esm/DropboxOAuthModel/index.d.ts +2 -0
- package/esm/DropboxOAuthModel/index.js +3 -0
- package/esm/DropboxOAuthModel/index.js.map +1 -0
- package/esm/DropboxOAuthModel/model.d.ts +98 -0
- package/esm/DropboxOAuthModel/model.js +96 -0
- package/esm/DropboxOAuthModel/model.js.map +1 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +5 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +29 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -0
- package/esm/ExternalTokenModel/configSchema.d.ts +5 -0
- package/esm/ExternalTokenModel/configSchema.js +24 -0
- package/esm/ExternalTokenModel/configSchema.js.map +1 -0
- package/esm/ExternalTokenModel/index.d.ts +2 -0
- package/esm/ExternalTokenModel/index.js +3 -0
- package/esm/ExternalTokenModel/index.js.map +1 -0
- package/esm/ExternalTokenModel/model.d.ts +67 -0
- package/esm/ExternalTokenModel/model.js +57 -0
- package/esm/ExternalTokenModel/model.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/configSchema.d.ts +5 -0
- package/esm/GoogleDriveOAuthModel/configSchema.js +48 -0
- package/esm/GoogleDriveOAuthModel/configSchema.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/index.d.ts +2 -0
- package/esm/GoogleDriveOAuthModel/index.js +3 -0
- package/esm/GoogleDriveOAuthModel/index.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/model.d.ts +111 -0
- package/esm/GoogleDriveOAuthModel/model.js +108 -0
- package/esm/GoogleDriveOAuthModel/model.js.map +1 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +5 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +28 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -0
- package/esm/HTTPBasicModel/configSchema.d.ts +5 -0
- package/esm/HTTPBasicModel/configSchema.js +32 -0
- package/esm/HTTPBasicModel/configSchema.js.map +1 -0
- package/esm/HTTPBasicModel/index.d.ts +2 -0
- package/esm/HTTPBasicModel/index.js +3 -0
- package/esm/HTTPBasicModel/index.js.map +1 -0
- package/esm/HTTPBasicModel/model.d.ts +67 -0
- package/esm/HTTPBasicModel/model.js +57 -0
- package/esm/HTTPBasicModel/model.js.map +1 -0
- package/esm/OAuthModel/configSchema.d.ts +5 -0
- package/esm/OAuthModel/configSchema.js +88 -0
- package/esm/OAuthModel/configSchema.js.map +1 -0
- package/esm/OAuthModel/index.d.ts +2 -0
- package/esm/OAuthModel/index.js +3 -0
- package/esm/OAuthModel/index.js.map +1 -0
- package/esm/OAuthModel/model.d.ts +91 -0
- package/esm/OAuthModel/model.js +289 -0
- package/esm/OAuthModel/model.js.map +1 -0
- package/esm/index.d.ts +399 -0
- package/esm/index.js +64 -0
- package/esm/index.js.map +1 -0
- package/package.json +63 -0
- package/src/DropboxOAuthModel/configSchema.ts +77 -0
- package/src/DropboxOAuthModel/index.ts +2 -0
- package/src/DropboxOAuthModel/model.tsx +141 -0
- package/src/ExternalTokenModel/ExternalTokenEntryForm.tsx +61 -0
- package/src/ExternalTokenModel/configSchema.ts +36 -0
- package/src/ExternalTokenModel/index.ts +2 -0
- package/src/ExternalTokenModel/model.tsx +70 -0
- package/src/GoogleDriveOAuthModel/configSchema.ts +61 -0
- package/src/GoogleDriveOAuthModel/index.ts +2 -0
- package/src/GoogleDriveOAuthModel/model.tsx +174 -0
- package/src/HTTPBasicModel/HTTPBasicLoginForm.tsx +71 -0
- package/src/HTTPBasicModel/configSchema.ts +43 -0
- package/src/HTTPBasicModel/index.ts +2 -0
- package/src/HTTPBasicModel/model.tsx +70 -0
- package/src/OAuthModel/configSchema.ts +98 -0
- package/src/OAuthModel/index.ts +2 -0
- package/src/OAuthModel/model.tsx +357 -0
- package/src/__snapshots__/index.test.js.snap +8 -0
- package/src/index.test.js +96 -0
- package/src/index.ts +97 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UriLocation } from '@jbrowse/core/util/types';
|
|
3
|
+
import { ExternalTokenInternetAccountConfigModel } from './configSchema';
|
|
4
|
+
import { Instance } from 'mobx-state-tree';
|
|
5
|
+
declare const stateModelFactory: (configSchema: ExternalTokenInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
6
|
+
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
7
|
+
type: import("mobx-state-tree").ISimpleType<string>;
|
|
8
|
+
} & {
|
|
9
|
+
type: import("mobx-state-tree").ISimpleType<"ExternalTokenInternetAccount">;
|
|
10
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly internetAccountId: string;
|
|
15
|
+
readonly authHeader: string;
|
|
16
|
+
readonly tokenType: string;
|
|
17
|
+
readonly domains: string[];
|
|
18
|
+
readonly toggleContents: import("react").ReactNode;
|
|
19
|
+
readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
|
|
20
|
+
readonly selectorLabel: string | undefined;
|
|
21
|
+
} & {
|
|
22
|
+
handlesLocation(location: UriLocation): boolean;
|
|
23
|
+
readonly tokenKey: string;
|
|
24
|
+
} & {
|
|
25
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
26
|
+
storeToken(token: string): void;
|
|
27
|
+
removeToken(): void;
|
|
28
|
+
retrieveToken(): string | null;
|
|
29
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
30
|
+
} & {
|
|
31
|
+
getToken(location?: UriLocation | undefined): Promise<string>;
|
|
32
|
+
} & {
|
|
33
|
+
addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
|
|
34
|
+
headers: Headers;
|
|
35
|
+
body?: BodyInit | null | undefined;
|
|
36
|
+
cache?: RequestCache | undefined;
|
|
37
|
+
credentials?: RequestCredentials | undefined;
|
|
38
|
+
integrity?: string | undefined;
|
|
39
|
+
keepalive?: boolean | undefined;
|
|
40
|
+
method?: string | undefined;
|
|
41
|
+
mode?: RequestMode | undefined;
|
|
42
|
+
redirect?: RequestRedirect | undefined;
|
|
43
|
+
referrer?: string | undefined;
|
|
44
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
45
|
+
signal?: AbortSignal | null | undefined;
|
|
46
|
+
window?: null | undefined;
|
|
47
|
+
};
|
|
48
|
+
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
49
|
+
internetAccountType: string;
|
|
50
|
+
authInfo: {
|
|
51
|
+
token: string;
|
|
52
|
+
configuration: any;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
} & {
|
|
56
|
+
getFetcher(location?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
57
|
+
} & {
|
|
58
|
+
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
59
|
+
} & {
|
|
60
|
+
readonly validateWithHEAD: boolean;
|
|
61
|
+
} & {
|
|
62
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
63
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
64
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
65
|
+
export default stateModelFactory;
|
|
66
|
+
export declare type ExternalTokenStateModel = ReturnType<typeof stateModelFactory>;
|
|
67
|
+
export declare type ExternalTokenModel = Instance<ExternalTokenStateModel>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
+
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
6
|
+
const ExternalTokenEntryForm_1 = require("./ExternalTokenEntryForm");
|
|
7
|
+
const stateModelFactory = (configSchema) => {
|
|
8
|
+
return models_1.InternetAccount.named('ExternalTokenInternetAccount')
|
|
9
|
+
.props({
|
|
10
|
+
type: mobx_state_tree_1.types.literal('ExternalTokenInternetAccount'),
|
|
11
|
+
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
12
|
+
})
|
|
13
|
+
.views(self => ({
|
|
14
|
+
get validateWithHEAD() {
|
|
15
|
+
return (0, configuration_1.getConf)(self, 'validateWithHEAD');
|
|
16
|
+
},
|
|
17
|
+
}))
|
|
18
|
+
.actions(self => ({
|
|
19
|
+
getTokenFromUser(resolve, reject) {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const { session } = (0, mobx_state_tree_1.getRoot)(self);
|
|
22
|
+
session.queueDialog((doneCallback) => [
|
|
23
|
+
ExternalTokenEntryForm_1.ExternalTokenEntryForm,
|
|
24
|
+
{
|
|
25
|
+
internetAccountId: self.internetAccountId,
|
|
26
|
+
handleClose: (token) => {
|
|
27
|
+
if (token) {
|
|
28
|
+
resolve(token);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
reject(new Error('user cancelled entry'));
|
|
32
|
+
}
|
|
33
|
+
doneCallback();
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
},
|
|
38
|
+
async validateToken(token, location) {
|
|
39
|
+
if (!self.validateWithHEAD) {
|
|
40
|
+
return token;
|
|
41
|
+
}
|
|
42
|
+
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
|
|
43
|
+
const response = await fetch(location.uri, newInit);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
let errorMessage;
|
|
46
|
+
try {
|
|
47
|
+
errorMessage = await response.text();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
errorMessage = '';
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`Token could not be validated — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
|
|
53
|
+
}
|
|
54
|
+
return token;
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
exports.default = stateModelFactory;
|
|
59
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/ExternalTokenModel/model.tsx"],"names":[],"mappings":";;AAAA,+DAA6E;AAC7E,uEAA4E;AAG5E,qDAA0D;AAE1D,qEAAiE;AAEjE,MAAM,iBAAiB,GAAG,CACxB,YAAqD,EACrD,EAAE;IACF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I,CAAC,QAAQ,CAAC,EAAE,EAAE;gBAChB,IAAI,YAAY,CAAA;gBAChB,IAAI;oBACF,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBACrC;gBAAC,OAAO,KAAK,EAAE;oBACd,YAAY,GAAG,EAAE,CAAA;iBAClB;gBACD,MAAM,IAAI,KAAK,CACb,kCAAkC,QAAQ,CAAC,MAAM,KAC/C,QAAQ,CAAC,UACX,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/C,CAAA;aACF;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC,CAAA;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Instance } from 'mobx-state-tree';
|
|
2
|
+
declare const GoogleDriveOAuthConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type GoogleDriveOAuthInternetAccountConfigModel = typeof GoogleDriveOAuthConfigSchema;
|
|
4
|
+
export declare type GoogleDriveOAuthInternetAccountConfig = Instance<GoogleDriveOAuthInternetAccountConfigModel>;
|
|
5
|
+
export default GoogleDriveOAuthConfigSchema;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
7
|
+
const configSchema_1 = __importDefault(require("../OAuthModel/configSchema"));
|
|
8
|
+
/**
|
|
9
|
+
* #config GoogleDriveOAuthInternetAccount
|
|
10
|
+
*/
|
|
11
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
|
+
const GoogleDriveOAuthConfigSchema = (0, configuration_1.ConfigurationSchema)('GoogleDriveOAuthInternetAccount', {
|
|
13
|
+
/**
|
|
14
|
+
* #slot
|
|
15
|
+
*/
|
|
16
|
+
authEndpoint: {
|
|
17
|
+
description: 'the authorization code endpoint of the internet account',
|
|
18
|
+
type: 'string',
|
|
19
|
+
defaultValue: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* #slot
|
|
23
|
+
*/
|
|
24
|
+
scopes: {
|
|
25
|
+
description: 'optional scopes for the authorization call',
|
|
26
|
+
type: 'string',
|
|
27
|
+
defaultValue: 'https://www.googleapis.com/auth/drive.readonly',
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* #slot
|
|
31
|
+
*/
|
|
32
|
+
domains: {
|
|
33
|
+
description: 'array of valid domains the url can contain to use this account',
|
|
34
|
+
type: 'stringArray',
|
|
35
|
+
defaultValue: ['drive.google.com"'],
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* #slot
|
|
39
|
+
*/
|
|
40
|
+
responseType: {
|
|
41
|
+
description: 'the type of response from the authorization endpoint',
|
|
42
|
+
type: 'string',
|
|
43
|
+
defaultValue: 'token',
|
|
44
|
+
},
|
|
45
|
+
}, {
|
|
46
|
+
/**
|
|
47
|
+
* #baseConfiguration
|
|
48
|
+
*/
|
|
49
|
+
baseConfiguration: configSchema_1.default,
|
|
50
|
+
explicitlyTyped: true,
|
|
51
|
+
});
|
|
52
|
+
exports.default = GoogleDriveOAuthConfigSchema;
|
|
53
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/configSchema.ts"],"names":[],"mappings":";;;;;AAAA,+DAAiE;AAEjE,8EAA0D;AAE1D;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,4BAA4B,GAAG,IAAA,mCAAmB,EACtD,iCAAiC,EACjC;IACE;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,yDAAyD;QACtE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,8CAA8C;KAC7D;IACD;;OAEG;IACH,MAAM,EAAE;QACN,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,gDAAgD;KAC/D;IACD;;OAEG;IACH,OAAO,EAAE;QACP,WAAW,EACT,gEAAgE;QAClE,IAAI,EAAE,aAAa;QACnB,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACpC;IACD;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,sDAAsD;QACnE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,OAAO;KACtB;CACF,EACD;IACE;;OAEG;IACH,iBAAiB,EAAE,sBAAiB;IACpC,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAOD,kBAAe,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.modelFactory = exports.configSchema = void 0;
|
|
7
|
+
var configSchema_1 = require("./configSchema");
|
|
8
|
+
Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_1).default; } });
|
|
9
|
+
var model_1 = require("./model");
|
|
10
|
+
Object.defineProperty(exports, "modelFactory", { enumerable: true, get: function () { return __importDefault(model_1).default; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAwD;AAA/C,6HAAA,OAAO,OAAgB;AAChC,iCAAiD;AAAxC,sHAAA,OAAO,OAAgB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Instance } from 'mobx-state-tree';
|
|
3
|
+
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
4
|
+
import { UriLocation } from '@jbrowse/core/util/types';
|
|
5
|
+
import { FilehandleOptions, Stats, PolyfilledResponse } from 'generic-filehandle';
|
|
6
|
+
import { GoogleDriveOAuthInternetAccountConfigModel } from './configSchema';
|
|
7
|
+
export interface RequestInitWithMetadata extends RequestInit {
|
|
8
|
+
metadataOnly?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface GoogleDriveFilehandleOptions extends FilehandleOptions {
|
|
11
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
12
|
+
}
|
|
13
|
+
export declare class GoogleDriveFile extends RemoteFileWithRangeCache {
|
|
14
|
+
private statsPromise;
|
|
15
|
+
constructor(source: string, opts: GoogleDriveFilehandleOptions);
|
|
16
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
17
|
+
stat(): Promise<Stats>;
|
|
18
|
+
}
|
|
19
|
+
declare const stateModelFactory: (configSchema: GoogleDriveOAuthInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
20
|
+
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
21
|
+
type: import("mobx-state-tree").ISimpleType<string>;
|
|
22
|
+
} & {
|
|
23
|
+
type: import("mobx-state-tree").ISimpleType<"OAuthInternetAccount">;
|
|
24
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
25
|
+
} & {
|
|
26
|
+
type: import("mobx-state-tree").ISimpleType<"GoogleDriveOAuthInternetAccount">;
|
|
27
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly description: string;
|
|
31
|
+
readonly internetAccountId: string;
|
|
32
|
+
readonly authHeader: string;
|
|
33
|
+
readonly tokenType: string;
|
|
34
|
+
readonly domains: string[];
|
|
35
|
+
readonly toggleContents: React.ReactNode;
|
|
36
|
+
readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
|
|
37
|
+
readonly selectorLabel: string | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
handlesLocation(location: UriLocation): boolean;
|
|
40
|
+
readonly tokenKey: string;
|
|
41
|
+
} & {
|
|
42
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
43
|
+
storeToken(token: string): void;
|
|
44
|
+
removeToken(): void;
|
|
45
|
+
retrieveToken(): string | null;
|
|
46
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
47
|
+
} & {
|
|
48
|
+
getToken(location?: UriLocation | undefined): Promise<string>;
|
|
49
|
+
} & {
|
|
50
|
+
addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
|
|
51
|
+
headers: Headers;
|
|
52
|
+
body?: BodyInit | null | undefined;
|
|
53
|
+
cache?: RequestCache | undefined;
|
|
54
|
+
credentials?: RequestCredentials | undefined;
|
|
55
|
+
integrity?: string | undefined;
|
|
56
|
+
keepalive?: boolean | undefined;
|
|
57
|
+
method?: string | undefined;
|
|
58
|
+
mode?: RequestMode | undefined;
|
|
59
|
+
redirect?: RequestRedirect | undefined;
|
|
60
|
+
referrer?: string | undefined;
|
|
61
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
62
|
+
signal?: AbortSignal | null | undefined;
|
|
63
|
+
window?: null | undefined;
|
|
64
|
+
};
|
|
65
|
+
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
66
|
+
internetAccountType: string;
|
|
67
|
+
authInfo: {
|
|
68
|
+
token: string;
|
|
69
|
+
configuration: any;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
} & {
|
|
73
|
+
getFetcher(location?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
74
|
+
} & {
|
|
75
|
+
openLocation(location: UriLocation): RemoteFileWithRangeCache;
|
|
76
|
+
} & {
|
|
77
|
+
readonly codeVerifierPKCE: string;
|
|
78
|
+
} & {
|
|
79
|
+
readonly authEndpoint: string;
|
|
80
|
+
readonly tokenEndpoint: string;
|
|
81
|
+
readonly needsPKCE: boolean;
|
|
82
|
+
readonly clientId: string;
|
|
83
|
+
readonly scopes: string;
|
|
84
|
+
state(): string | undefined;
|
|
85
|
+
readonly responseType: "code" | "token";
|
|
86
|
+
readonly hasRefreshToken: boolean;
|
|
87
|
+
readonly refreshTokenKey: string;
|
|
88
|
+
} & {
|
|
89
|
+
storeRefreshToken(refreshToken: string): void;
|
|
90
|
+
removeRefreshToken(): void;
|
|
91
|
+
retrieveRefreshToken(): string | null;
|
|
92
|
+
exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
|
|
93
|
+
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
94
|
+
} & {
|
|
95
|
+
addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
96
|
+
deleteMessageChannel(): void;
|
|
97
|
+
finishOAuthWindow(event: MessageEvent<any>, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
98
|
+
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
99
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
100
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
101
|
+
} & {
|
|
102
|
+
readonly toggleContents: JSX.Element;
|
|
103
|
+
readonly selectorLabel: string;
|
|
104
|
+
} & {
|
|
105
|
+
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
106
|
+
openLocation(location: UriLocation): GoogleDriveFile;
|
|
107
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
108
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
109
|
+
export default stateModelFactory;
|
|
110
|
+
export declare type GoogleDriveOAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
111
|
+
export declare type GoogleDriveOAuthModel = Instance<GoogleDriveOAuthStateModel>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GoogleDriveFile = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
9
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
10
|
+
const io_1 = require("@jbrowse/core/util/io");
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const model_1 = __importDefault(require("../OAuthModel/model"));
|
|
13
|
+
const OAuthModel_1 = require("../OAuthModel");
|
|
14
|
+
class GoogleDriveFile extends io_1.RemoteFileWithRangeCache {
|
|
15
|
+
constructor(source, opts) {
|
|
16
|
+
super(source, opts);
|
|
17
|
+
this.statsPromise = this.fetch(source, {
|
|
18
|
+
metadataOnly: true,
|
|
19
|
+
}).then((response) => response.json());
|
|
20
|
+
}
|
|
21
|
+
async fetch(input, opts) {
|
|
22
|
+
return super.fetch(input, opts);
|
|
23
|
+
}
|
|
24
|
+
async stat() {
|
|
25
|
+
return this.statsPromise;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.GoogleDriveFile = GoogleDriveFile;
|
|
29
|
+
function GoogleDriveIcon(props) {
|
|
30
|
+
return (react_1.default.createElement(material_1.SvgIcon, { ...props },
|
|
31
|
+
react_1.default.createElement("path", { d: "M7.71,3.5L1.15,15L4.58,21L11.13,9.5M9.73,15L6.3,21H19.42L22.85,15M22.28,14L15.42,2H8.58L8.57,2L15.43,14H22.28Z" })));
|
|
32
|
+
}
|
|
33
|
+
async function getDescriptiveErrorMessage(response) {
|
|
34
|
+
let errorMessage;
|
|
35
|
+
try {
|
|
36
|
+
errorMessage = await response.text();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
errorMessage = '';
|
|
40
|
+
}
|
|
41
|
+
if (errorMessage) {
|
|
42
|
+
let errorMessageParsed;
|
|
43
|
+
try {
|
|
44
|
+
errorMessageParsed = JSON.parse(errorMessage);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
errorMessageParsed = undefined;
|
|
48
|
+
}
|
|
49
|
+
if (errorMessageParsed) {
|
|
50
|
+
errorMessage = errorMessageParsed.error.message;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
54
|
+
}
|
|
55
|
+
const stateModelFactory = (configSchema) => {
|
|
56
|
+
return (0, model_1.default)(OAuthModel_1.configSchema)
|
|
57
|
+
.named('GoogleDriveOAuthInternetAccount')
|
|
58
|
+
.props({
|
|
59
|
+
type: mobx_state_tree_1.types.literal('GoogleDriveOAuthInternetAccount'),
|
|
60
|
+
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
61
|
+
})
|
|
62
|
+
.views(() => ({
|
|
63
|
+
get toggleContents() {
|
|
64
|
+
return react_1.default.createElement(GoogleDriveIcon, null);
|
|
65
|
+
},
|
|
66
|
+
get selectorLabel() {
|
|
67
|
+
return 'Enter Google Drive share link';
|
|
68
|
+
},
|
|
69
|
+
}))
|
|
70
|
+
.actions(self => ({
|
|
71
|
+
getFetcher(location) {
|
|
72
|
+
return async (input, init) => {
|
|
73
|
+
const urlId = String(input).match(/[-\w]{25,}/);
|
|
74
|
+
const driveUrl = new URL(`https://www.googleapis.com/drive/v3/files/${urlId}`);
|
|
75
|
+
const searchParams = new URLSearchParams();
|
|
76
|
+
if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
|
|
77
|
+
searchParams.append('fields', 'size');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
searchParams.append('alt', 'media');
|
|
81
|
+
}
|
|
82
|
+
driveUrl.search = searchParams.toString();
|
|
83
|
+
const authToken = await self.getToken(location);
|
|
84
|
+
const newInit = self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken);
|
|
85
|
+
const response = await fetch(driveUrl.toString(), newInit);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
88
|
+
throw new Error(message);
|
|
89
|
+
}
|
|
90
|
+
return response;
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
openLocation(location) {
|
|
94
|
+
return new GoogleDriveFile(location.uri, {
|
|
95
|
+
fetch: this.getFetcher(location),
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
async validateToken(token, location) {
|
|
99
|
+
const urlId = location.uri.match(/[-\w]{25,}/);
|
|
100
|
+
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${urlId}`, {
|
|
101
|
+
headers: {
|
|
102
|
+
Authorization: `Bearer ${token}`,
|
|
103
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
108
|
+
throw new Error(`Token could not be validated. ${message}`);
|
|
109
|
+
}
|
|
110
|
+
return token;
|
|
111
|
+
},
|
|
112
|
+
}));
|
|
113
|
+
};
|
|
114
|
+
exports.default = stateModelFactory;
|
|
115
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/model.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB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C,CAAC,CAAA;AACP,CAAC,CAAA;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HTTPBasicLoginForm = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const material_1 = require("@mui/material");
|
|
29
|
+
const HTTPBasicLoginForm = ({ internetAccountId, handleClose, }) => {
|
|
30
|
+
const [username, setUsername] = (0, react_1.useState)('');
|
|
31
|
+
const [password, setPassword] = (0, react_1.useState)('');
|
|
32
|
+
function onSubmit(event) {
|
|
33
|
+
if (username && password) {
|
|
34
|
+
handleClose(btoa(`${username}:${password}`));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
handleClose();
|
|
38
|
+
}
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
}
|
|
41
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
42
|
+
react_1.default.createElement(material_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic" },
|
|
43
|
+
react_1.default.createElement(material_1.DialogTitle, null,
|
|
44
|
+
"Log In for ",
|
|
45
|
+
internetAccountId),
|
|
46
|
+
react_1.default.createElement("form", { onSubmit: onSubmit },
|
|
47
|
+
react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
|
|
48
|
+
react_1.default.createElement(material_1.TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
|
|
49
|
+
react_1.default.createElement(material_1.TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => setPassword(event.target.value), margin: "dense" })),
|
|
50
|
+
react_1.default.createElement(material_1.DialogActions, null,
|
|
51
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
|
|
52
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", type: "submit", onClick: () => handleClose() }, "Cancel"))))));
|
|
53
|
+
};
|
|
54
|
+
exports.HTTPBasicLoginForm = HTTPBasicLoginForm;
|
|
55
|
+
//# sourceMappingURL=HTTPBasicLoginForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPBasicLoginForm.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/HTTPBasicLoginForm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AACvC,4CAOsB;AAEf,MAAM,kBAAkB,GAAG,CAAC,EACjC,iBAA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C,EAClD,MAAM,EAAC,OAAO,GACd,CACY;gBAChB,8BAAC,wBAAa;oBACZ,8BAAC,iBAAM,IAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,aAEhD;oBACT,8BAAC,iBAAM,IACL,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,aAGrB,CACK,CACX,CACA,CACR,CACJ,CAAA;AACH,CAAC,CAAA;AA5DY,QAAA,kBAAkB,sBA4D9B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Instance } from 'mobx-state-tree';
|
|
2
|
+
declare const HTTPBasicConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type HTTPBasicInternetAccountConfigModel = typeof HTTPBasicConfigSchema;
|
|
4
|
+
export declare type HTTPBasicInternetAccountConfig = Instance<HTTPBasicInternetAccountConfigModel>;
|
|
5
|
+
export default HTTPBasicConfigSchema;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
+
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
|
+
/**
|
|
6
|
+
* #config HTTPBasicInternetAccount
|
|
7
|
+
*/
|
|
8
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
9
|
+
const HTTPBasicConfigSchema = (0, configuration_1.ConfigurationSchema)('HTTPBasicInternetAccount', {
|
|
10
|
+
/**
|
|
11
|
+
* #slot
|
|
12
|
+
*/
|
|
13
|
+
tokenType: {
|
|
14
|
+
description: 'a custom name for a token to include in the header',
|
|
15
|
+
type: 'string',
|
|
16
|
+
defaultValue: 'Basic',
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* #slot
|
|
20
|
+
*/
|
|
21
|
+
validateWithHEAD: {
|
|
22
|
+
description: 'validate the token with a HEAD request before using it',
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
defaultValue: true,
|
|
25
|
+
},
|
|
26
|
+
}, {
|
|
27
|
+
/**
|
|
28
|
+
* #baseConfiguration
|
|
29
|
+
*/
|
|
30
|
+
baseConfiguration: models_1.BaseInternetAccountConfig,
|
|
31
|
+
explicitlyTyped: true,
|
|
32
|
+
});
|
|
33
|
+
exports.default = HTTPBasicConfigSchema;
|
|
34
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/configSchema.ts"],"names":[],"mappings":";;AAAA,+DAAiE;AAEjE,uEAAsF;AAEtF;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,qBAAqB,GAAG,IAAA,mCAAmB,EAC/C,0BAA0B,EAC1B;IACE;;OAEG;IACH,SAAS,EAAE;QACT,WAAW,EAAE,oDAAoD;QACjE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,OAAO;KACtB;IACD;;OAEG;IACH,gBAAgB,EAAE;QAChB,WAAW,EAAE,wDAAwD;QACrE,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;KACnB;CACF,EACD;IACE;;OAEG;IACH,iBAAiB,EAAE,kCAAyB;IAC5C,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAMD,kBAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.modelFactory = exports.configSchema = void 0;
|
|
7
|
+
var configSchema_1 = require("./configSchema");
|
|
8
|
+
Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_1).default; } });
|
|
9
|
+
var model_1 = require("./model");
|
|
10
|
+
Object.defineProperty(exports, "modelFactory", { enumerable: true, get: function () { return __importDefault(model_1).default; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAwD;AAA/C,6HAAA,OAAO,OAAgB;AAChC,iCAAiD;AAAxC,sHAAA,OAAO,OAAgB"}
|