latchkey 3.14.0 → 3.15.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.
Files changed (140) hide show
  1. package/README.md +10 -0
  2. package/dist/src/apiCredentials/base.d.ts +53 -5
  3. package/dist/src/apiCredentials/base.d.ts.map +1 -1
  4. package/dist/src/apiCredentials/base.js +43 -9
  5. package/dist/src/apiCredentials/base.js.map +1 -1
  6. package/dist/src/apiCredentials/serialization.d.ts +11 -139
  7. package/dist/src/apiCredentials/serialization.d.ts.map +1 -1
  8. package/dist/src/apiCredentials/serialization.js +53 -81
  9. package/dist/src/apiCredentials/serialization.js.map +1 -1
  10. package/dist/src/apiCredentials/store.d.ts +7 -2
  11. package/dist/src/apiCredentials/store.d.ts.map +1 -1
  12. package/dist/src/apiCredentials/store.js +18 -8
  13. package/dist/src/apiCredentials/store.js.map +1 -1
  14. package/dist/src/cli.js +13 -2
  15. package/dist/src/cli.js.map +1 -1
  16. package/dist/src/cliCommands.d.ts +15 -7
  17. package/dist/src/cliCommands.d.ts.map +1 -1
  18. package/dist/src/cliCommands.js +27 -16
  19. package/dist/src/cliCommands.js.map +1 -1
  20. package/dist/src/config.d.ts +10 -0
  21. package/dist/src/config.d.ts.map +1 -1
  22. package/dist/src/config.js +15 -0
  23. package/dist/src/config.js.map +1 -1
  24. package/dist/src/configDataStore.d.ts +3 -0
  25. package/dist/src/configDataStore.d.ts.map +1 -1
  26. package/dist/src/configDataStore.js +1 -0
  27. package/dist/src/configDataStore.js.map +1 -1
  28. package/dist/src/curlInjection.d.ts +2 -0
  29. package/dist/src/curlInjection.d.ts.map +1 -1
  30. package/dist/src/curlInjection.js +12 -6
  31. package/dist/src/curlInjection.js.map +1 -1
  32. package/dist/src/diagnosticHeaders.d.ts +19 -0
  33. package/dist/src/diagnosticHeaders.d.ts.map +1 -0
  34. package/dist/src/diagnosticHeaders.js +20 -0
  35. package/dist/src/diagnosticHeaders.js.map +1 -0
  36. package/dist/src/gateway/gatewayEndpoint.d.ts.map +1 -1
  37. package/dist/src/gateway/gatewayEndpoint.js +1 -0
  38. package/dist/src/gateway/gatewayEndpoint.js.map +1 -1
  39. package/dist/src/gateway/server.js +1 -1
  40. package/dist/src/gateway/server.js.map +1 -1
  41. package/dist/src/index.d.ts +2 -2
  42. package/dist/src/index.d.ts.map +1 -1
  43. package/dist/src/index.js +1 -1
  44. package/dist/src/index.js.map +1 -1
  45. package/dist/src/migrations.d.ts.map +1 -1
  46. package/dist/src/migrations.js +8 -8
  47. package/dist/src/migrations.js.map +1 -1
  48. package/dist/src/oauthUtils.d.ts +17 -0
  49. package/dist/src/oauthUtils.d.ts.map +1 -1
  50. package/dist/src/oauthUtils.js +22 -1
  51. package/dist/src/oauthUtils.js.map +1 -1
  52. package/dist/src/pluginSdk.d.ts +117 -0
  53. package/dist/src/pluginSdk.d.ts.map +1 -0
  54. package/dist/src/pluginSdk.js +97 -0
  55. package/dist/src/pluginSdk.js.map +1 -0
  56. package/dist/src/plugins.d.ts +74 -0
  57. package/dist/src/plugins.d.ts.map +1 -0
  58. package/dist/src/plugins.js +221 -0
  59. package/dist/src/plugins.js.map +1 -0
  60. package/dist/src/serviceRegistry.d.ts +2 -2
  61. package/dist/src/serviceRegistry.d.ts.map +1 -1
  62. package/dist/src/serviceRegistry.js +3 -3
  63. package/dist/src/serviceRegistry.js.map +1 -1
  64. package/dist/src/services/aws.d.ts +2 -1
  65. package/dist/src/services/aws.d.ts.map +1 -1
  66. package/dist/src/services/aws.js +4 -2
  67. package/dist/src/services/aws.js.map +1 -1
  68. package/dist/src/services/core/base.d.ts +42 -2
  69. package/dist/src/services/core/base.d.ts.map +1 -1
  70. package/dist/src/services/core/base.js +48 -1
  71. package/dist/src/services/core/base.js.map +1 -1
  72. package/dist/src/services/dropbox.d.ts.map +1 -1
  73. package/dist/src/services/dropbox.js +2 -2
  74. package/dist/src/services/dropbox.js.map +1 -1
  75. package/dist/src/services/fastmail.d.ts +4 -19
  76. package/dist/src/services/fastmail.d.ts.map +1 -1
  77. package/dist/src/services/fastmail.js +17 -22
  78. package/dist/src/services/fastmail.js.map +1 -1
  79. package/dist/src/services/google/base.d.ts +8 -3
  80. package/dist/src/services/google/base.d.ts.map +1 -1
  81. package/dist/src/services/google/base.js +23 -13
  82. package/dist/src/services/google/base.js.map +1 -1
  83. package/dist/src/services/notion-mcp.d.ts +16 -16
  84. package/dist/src/services/notion-mcp.d.ts.map +1 -1
  85. package/dist/src/services/notion-mcp.js +36 -21
  86. package/dist/src/services/notion-mcp.js.map +1 -1
  87. package/dist/src/services/ramp.d.ts.map +1 -1
  88. package/dist/src/services/ramp.js +2 -2
  89. package/dist/src/services/ramp.js.map +1 -1
  90. package/dist/src/services/slack.d.ts +2 -1
  91. package/dist/src/services/slack.d.ts.map +1 -1
  92. package/dist/src/services/slack.js +4 -2
  93. package/dist/src/services/slack.js.map +1 -1
  94. package/dist/src/services/tailscale.d.ts +2 -1
  95. package/dist/src/services/tailscale.d.ts.map +1 -1
  96. package/dist/src/services/tailscale.js +4 -2
  97. package/dist/src/services/tailscale.js.map +1 -1
  98. package/dist/src/services/telegram.d.ts +2 -1
  99. package/dist/src/services/telegram.d.ts.map +1 -1
  100. package/dist/src/services/telegram.js +4 -2
  101. package/dist/src/services/telegram.js.map +1 -1
  102. package/dist/src/services/zoom.d.ts +2 -1
  103. package/dist/src/services/zoom.d.ts.map +1 -1
  104. package/dist/src/services/zoom.js +4 -2
  105. package/dist/src/services/zoom.js.map +1 -1
  106. package/dist/src/version.d.ts +1 -1
  107. package/dist/src/version.js +1 -1
  108. package/dist/tests/apiCredentialStore.test.js +54 -1
  109. package/dist/tests/apiCredentialStore.test.js.map +1 -1
  110. package/dist/tests/apiCredentials.test.js +73 -12
  111. package/dist/tests/apiCredentials.test.js.map +1 -1
  112. package/dist/tests/cli.test.js +32 -1
  113. package/dist/tests/cli.test.js.map +1 -1
  114. package/dist/tests/config.test.js +7 -0
  115. package/dist/tests/config.test.js.map +1 -1
  116. package/dist/tests/diagnosticHeaders.test.d.ts +2 -0
  117. package/dist/tests/diagnosticHeaders.test.d.ts.map +1 -0
  118. package/dist/tests/diagnosticHeaders.test.js +22 -0
  119. package/dist/tests/diagnosticHeaders.test.js.map +1 -0
  120. package/dist/tests/gateway.test.js +25 -4
  121. package/dist/tests/gateway.test.js.map +1 -1
  122. package/dist/tests/gatewayExtensions.test.js +5 -2
  123. package/dist/tests/gatewayExtensions.test.js.map +1 -1
  124. package/dist/tests/latchkeyEndpoint.test.js +8 -6
  125. package/dist/tests/latchkeyEndpoint.test.js.map +1 -1
  126. package/dist/tests/notion-mcp.test.d.ts +2 -0
  127. package/dist/tests/notion-mcp.test.d.ts.map +1 -0
  128. package/dist/tests/notion-mcp.test.js +16 -0
  129. package/dist/tests/notion-mcp.test.js.map +1 -0
  130. package/dist/tests/oauthUtils.test.js +23 -1
  131. package/dist/tests/oauthUtils.test.js.map +1 -1
  132. package/dist/tests/plugins.test.d.ts +2 -0
  133. package/dist/tests/plugins.test.d.ts.map +1 -0
  134. package/dist/tests/plugins.test.js +506 -0
  135. package/dist/tests/plugins.test.js.map +1 -0
  136. package/dist/tests/sharedOperations.test.js +63 -2
  137. package/dist/tests/sharedOperations.test.js.map +1 -1
  138. package/dist/tests/tailscale.test.js +1 -3
  139. package/dist/tests/tailscale.test.js.map +1 -1
  140. package/package.json +15 -1
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Generic OAuth utilities for localhost callback server and token exchange.
3
3
  */
4
+ import { type ApiCredentials } from './apiCredentials/base.js';
4
5
  export interface OAuthTokenResponse {
5
6
  access_token: string;
6
7
  refresh_token?: string;
@@ -16,6 +17,22 @@ export declare class OAuthTokenExchangeError extends Error {
16
17
  export declare class OAuthCallbackServerTimeoutError extends Error {
17
18
  constructor();
18
19
  }
20
+ /**
21
+ * The path the loopback callback server listens on by default.
22
+ */
23
+ export declare const DEFAULT_OAUTH_CALLBACK_PATH = "/oauth2callback";
24
+ /**
25
+ * The loopback redirect URI for a login that receives the authorization code
26
+ * itself, on the port {@link startOAuthCallbackServer} picked.
27
+ */
28
+ export declare function buildLoopbackRedirectUri(port: number, callbackPath?: string): string;
29
+ /**
30
+ * The pre-registered redirect URI to use instead of a loopback one, as stored
31
+ * by `latchkey auth prepare`; undefined when there is none and login should
32
+ * receive the authorization code directly. See
33
+ * {@link OAuthCredentials.redirectUri}.
34
+ */
35
+ export declare function readRedirectUriOverride(credentials?: ApiCredentials): string | undefined;
19
36
  export interface OAuthCallbackServer {
20
37
  /** The port the server is listening on */
21
38
  port: number;
@@ -1 +1 @@
1
- {"version":3,"file":"oauthUtils.d.ts","sourceRoot":"","sources":["../../src/oauthUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,+BAAgC,SAAQ,KAAK;;CAKzD;AAED,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,SAAoB,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CA8F9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;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;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAExF;AAED,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,GAAE,MAAoC,GACjD,OAAO,CAAC,mBAAmB,CAAC,CA8F9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC7C,OAAO,CAAC,0BAA0B,CAAC,CA6DrC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC7C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAuCpC"}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as crypto from 'node:crypto';
5
5
  import * as http from 'node:http';
6
+ import { OAuthCredentials } from './apiCredentials/base.js';
6
7
  import { runCapturedAsync } from './curl.js';
7
8
  import { LoginCancelledError, LoginFailedError } from './services/core/base.js';
8
9
  export class OAuthTokenExchangeError extends Error {
@@ -17,6 +18,26 @@ export class OAuthCallbackServerTimeoutError extends Error {
17
18
  this.name = 'OAuthCallbackServerTimeoutError';
18
19
  }
19
20
  }
21
+ /**
22
+ * The path the loopback callback server listens on by default.
23
+ */
24
+ export const DEFAULT_OAUTH_CALLBACK_PATH = '/oauth2callback';
25
+ /**
26
+ * The loopback redirect URI for a login that receives the authorization code
27
+ * itself, on the port {@link startOAuthCallbackServer} picked.
28
+ */
29
+ export function buildLoopbackRedirectUri(port, callbackPath = DEFAULT_OAUTH_CALLBACK_PATH) {
30
+ return `http://localhost:${port.toString()}${callbackPath}`;
31
+ }
32
+ /**
33
+ * The pre-registered redirect URI to use instead of a loopback one, as stored
34
+ * by `latchkey auth prepare`; undefined when there is none and login should
35
+ * receive the authorization code directly. See
36
+ * {@link OAuthCredentials.redirectUri}.
37
+ */
38
+ export function readRedirectUriOverride(credentials) {
39
+ return credentials instanceof OAuthCredentials ? credentials.redirectUri : undefined;
40
+ }
20
41
  /**
21
42
  * Start a temporary HTTP server to receive OAuth callback.
22
43
  * Returns the assigned port and a promise that resolves with the authorization code.
@@ -25,7 +46,7 @@ export class OAuthCallbackServerTimeoutError extends Error {
25
46
  * @param signal - Optional AbortSignal to cancel the server early
26
47
  * @param callbackPath - Path to listen for OAuth callback (default: '/oauth2callback')
27
48
  */
28
- export function startOAuthCallbackServer(timeoutMs, signal, callbackPath = '/oauth2callback') {
49
+ export function startOAuthCallbackServer(timeoutMs, signal, callbackPath = DEFAULT_OAUTH_CALLBACK_PATH) {
29
50
  const server = http.createServer();
30
51
  return new Promise((resolveServer, rejectServer) => {
31
52
  server.on('error', (error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"oauthUtils.js","sourceRoot":"","sources":["../../src/oauthUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,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e,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,CACnC;QACE,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,IAAI;QACJ,iDAAiD;QACjD,IAAI;QACJ,IAAI,CAAC,QAAQ,EAAE;QACf,aAAa;KACd,EACD,EAAE,CACH,CAAC;IAEF,IAAI,MAAM,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAuB,CAAC;QACjE,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The `latchkey/plugin` entry point.
3
+ *
4
+ * At runtime, this builds the object handed to a plugin's factory: every value
5
+ * a plugin may use, so that a bare clone with no node_modules of its own has
6
+ * everything it needs. For plugin authors, it is also where the types come
7
+ * from, with `import type { LatchkeySdk, Service } from 'latchkey/plugin'`.
8
+ * That is the only way a plugin imports from it: the SDK object, not this
9
+ * module, is what carries the classes and helpers.
10
+ *
11
+ * Plugins declare the Latchkey versions they support as a semver range (see
12
+ * `src/plugins.ts`), so this surface follows semantic versioning: additions
13
+ * are welcome in any release, while removing or changing anything here is a
14
+ * breaking change that calls for a new major version of Latchkey.
15
+ */
16
+ import { z } from 'zod';
17
+ import { ApiCredentialStatus, ApiCredentialsUsageError, AuthorizationBare, AuthorizationBearer, OAuthCredentials, RawCurlCredentials } from './apiCredentials/base.js';
18
+ import { fetchAccountFromEndpoint, tryParseJson } from './apiCredentials/account.js';
19
+ import { runCapturedAsync } from './curl.js';
20
+ import { OAuthCallbackServerTimeoutError, OAuthTokenExchangeError, buildLoopbackRedirectUri, exchangeCodeForTokens, generateCodeChallenge, generateCodeVerifier, readRedirectUriOverride, refreshAccessToken, startOAuthCallbackServer } from './oauthUtils.js';
21
+ import { BrowserFeaturesUnavailableError, loadPlaywright } from './playwrightLoader.js';
22
+ import { BrowserDisabledError, BrowserFlowsNotSupportedError, CredentialFormFieldMissingError, CredentialFormValues, GraphicalEnvironmentNotFoundError, generateLatchkeyAppName, hasGraphicalEnvironment, requestCredentialsFromUser, showSpinnerPage, typeLikeHuman, withTempBrowserContext } from './playwrightUtils.js';
23
+ import { BrowserFollowupServiceSession, FollowupWork, LoginCancelledError, LoginFailedError, NoCurlCredentialsNotSupportedError, PrepareInputInvalidError, PrepareNotSupportedError, Service, ServiceSession, SimpleServiceSession, buildDynamicClientPreparation, buildFollowupSpinnerDetails, buildPreparedCredentials, describeSchemaIssues, isBrowserClosedError, isResponseBodyUnavailableError, isTimeoutError } from './services/core/base.js';
24
+ import { CookieCaptureLoginFlow } from './services/core/loginFlows/cookieCapture.js';
25
+ import { TokenCaptureLoginFlow } from './services/core/loginFlows/tokenCapture.js';
26
+ import { RegisteredService } from './services/core/registered.js';
27
+ import { GoogleService } from './services/google/base.js';
28
+ export declare function createLatchkeySdk(latchkeyVersion: string): Readonly<{
29
+ latchkeyVersion: string;
30
+ z: typeof z;
31
+ builtinServices: readonly Service[];
32
+ Service: typeof Service;
33
+ ServiceSession: typeof ServiceSession;
34
+ SimpleServiceSession: typeof SimpleServiceSession;
35
+ BrowserFollowupServiceSession: typeof BrowserFollowupServiceSession;
36
+ FollowupWork: typeof FollowupWork;
37
+ RegisteredService: typeof RegisteredService;
38
+ GoogleService: typeof GoogleService;
39
+ CookieCaptureLoginFlow: typeof CookieCaptureLoginFlow;
40
+ TokenCaptureLoginFlow: typeof TokenCaptureLoginFlow;
41
+ buildDynamicClientPreparation: typeof buildDynamicClientPreparation;
42
+ buildFollowupSpinnerDetails: typeof buildFollowupSpinnerDetails;
43
+ buildPreparedCredentials: typeof buildPreparedCredentials;
44
+ describeSchemaIssues: typeof describeSchemaIssues;
45
+ isBrowserClosedError: typeof isBrowserClosedError;
46
+ isResponseBodyUnavailableError: typeof isResponseBodyUnavailableError;
47
+ isTimeoutError: typeof isTimeoutError;
48
+ LoginCancelledError: typeof LoginCancelledError;
49
+ LoginFailedError: typeof LoginFailedError;
50
+ NoCurlCredentialsNotSupportedError: typeof NoCurlCredentialsNotSupportedError;
51
+ PrepareNotSupportedError: typeof PrepareNotSupportedError;
52
+ PrepareInputInvalidError: typeof PrepareInputInvalidError;
53
+ RedirectUriOverrideSchema: z.ZodEffects<z.ZodString, string, string>;
54
+ DynamicClientPrepareInputSchema: z.ZodEffects<z.ZodObject<{
55
+ clientId: z.ZodOptional<z.ZodString>;
56
+ redirectUri: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
57
+ }, "strict", z.ZodTypeAny, {
58
+ clientId?: string | undefined;
59
+ redirectUri?: string | undefined;
60
+ }, {
61
+ clientId?: string | undefined;
62
+ redirectUri?: string | undefined;
63
+ }>, {
64
+ clientId?: string | undefined;
65
+ redirectUri?: string | undefined;
66
+ }, {
67
+ clientId?: string | undefined;
68
+ redirectUri?: string | undefined;
69
+ }>;
70
+ ApiCredentialStatus: typeof ApiCredentialStatus;
71
+ ApiCredentialsUsageError: typeof ApiCredentialsUsageError;
72
+ AuthorizationBearer: typeof AuthorizationBearer;
73
+ AuthorizationBare: typeof AuthorizationBare;
74
+ RawCurlCredentials: typeof RawCurlCredentials;
75
+ OAuthCredentials: typeof OAuthCredentials;
76
+ DEFAULT_ACCOUNT: "";
77
+ fetchAccountFromEndpoint: typeof fetchAccountFromEndpoint;
78
+ tryParseJson: typeof tryParseJson;
79
+ loadPlaywright: typeof loadPlaywright;
80
+ withTempBrowserContext: typeof withTempBrowserContext;
81
+ showSpinnerPage: typeof showSpinnerPage;
82
+ requestCredentialsFromUser: typeof requestCredentialsFromUser;
83
+ typeLikeHuman: typeof typeLikeHuman;
84
+ generateLatchkeyAppName: typeof generateLatchkeyAppName;
85
+ hasGraphicalEnvironment: typeof hasGraphicalEnvironment;
86
+ CredentialFormValues: typeof CredentialFormValues;
87
+ CredentialFormFieldMissingError: typeof CredentialFormFieldMissingError;
88
+ BrowserDisabledError: typeof BrowserDisabledError;
89
+ BrowserFlowsNotSupportedError: typeof BrowserFlowsNotSupportedError;
90
+ BrowserFeaturesUnavailableError: typeof BrowserFeaturesUnavailableError;
91
+ GraphicalEnvironmentNotFoundError: typeof GraphicalEnvironmentNotFoundError;
92
+ startOAuthCallbackServer: typeof startOAuthCallbackServer;
93
+ DEFAULT_OAUTH_CALLBACK_PATH: "/oauth2callback";
94
+ buildLoopbackRedirectUri: typeof buildLoopbackRedirectUri;
95
+ readRedirectUriOverride: typeof readRedirectUriOverride;
96
+ exchangeCodeForTokens: typeof exchangeCodeForTokens;
97
+ refreshAccessToken: typeof refreshAccessToken;
98
+ generateCodeVerifier: typeof generateCodeVerifier;
99
+ generateCodeChallenge: typeof generateCodeChallenge;
100
+ OAuthTokenExchangeError: typeof OAuthTokenExchangeError;
101
+ OAuthCallbackServerTimeoutError: typeof OAuthCallbackServerTimeoutError;
102
+ runCurlCapturedAsync: typeof runCapturedAsync;
103
+ }>;
104
+ export type LatchkeySdk = ReturnType<typeof createLatchkeySdk>;
105
+ export type { LatchkeyPlugin, LatchkeyPluginFactory } from './plugins.js';
106
+ export type { Service, ServiceSession, SimpleServiceSession, BrowserFollowupServiceSession, LoginResult, ManualCredentialForm, } from './services/core/base.js';
107
+ export type { RegisteredService, RegisteredServiceOptions } from './services/core/registered.js';
108
+ export type { LoginFlow } from './services/core/loginFlows/base.js';
109
+ export type { GoogleService } from './services/google/base.js';
110
+ export type { ApiCredentials, ApiCredentialsType, AuthorizationBare, AuthorizationBearer, OAuthCredentials, RawCurlCredentials, SerializedApiCredentials, } from './apiCredentials/base.js';
111
+ export type { EncryptedStorage } from './encryptedStorage.js';
112
+ export type { BrowserLaunchOptions, BrowserWithContext, CredentialFormDecision, CredentialFormField, CredentialFormValues, CredentialRequest, } from './playwrightUtils.js';
113
+ export type { OAuthCallbackServer, OAuthTokenExchangeResponse, OAuthTokenResponse, } from './oauthUtils.js';
114
+ export type { CurlResult } from './curl.js';
115
+ export type { Browser, BrowserContext, Locator, Page, Response } from 'playwright';
116
+ export type { z } from 'zod';
117
+ //# sourceMappingURL=pluginSdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginSdk.d.ts","sourceRoot":"","sources":["../../src/pluginSdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,wBAAwB,EACxB,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAEL,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,+BAA+B,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,+BAA+B,EAC/B,oBAAoB,EACpB,iCAAiC,EACjC,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,aAAa,EACb,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,EAE7B,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,kCAAkC,EAClC,wBAAwB,EACxB,wBAAwB,EAExB,OAAO,EACP,cAAc,EACd,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EACV,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnF,YAAY,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The `latchkey/plugin` entry point.
3
+ *
4
+ * At runtime, this builds the object handed to a plugin's factory: every value
5
+ * a plugin may use, so that a bare clone with no node_modules of its own has
6
+ * everything it needs. For plugin authors, it is also where the types come
7
+ * from, with `import type { LatchkeySdk, Service } from 'latchkey/plugin'`.
8
+ * That is the only way a plugin imports from it: the SDK object, not this
9
+ * module, is what carries the classes and helpers.
10
+ *
11
+ * Plugins declare the Latchkey versions they support as a semver range (see
12
+ * `src/plugins.ts`), so this surface follows semantic versioning: additions
13
+ * are welcome in any release, while removing or changing anything here is a
14
+ * breaking change that calls for a new major version of Latchkey.
15
+ */
16
+ import { z } from 'zod';
17
+ import { ApiCredentialStatus, ApiCredentialsUsageError, AuthorizationBare, AuthorizationBearer, OAuthCredentials, RawCurlCredentials, } from './apiCredentials/base.js';
18
+ import { DEFAULT_ACCOUNT, fetchAccountFromEndpoint, tryParseJson, } from './apiCredentials/account.js';
19
+ import { runCapturedAsync } from './curl.js';
20
+ import { DEFAULT_OAUTH_CALLBACK_PATH, OAuthCallbackServerTimeoutError, OAuthTokenExchangeError, buildLoopbackRedirectUri, exchangeCodeForTokens, generateCodeChallenge, generateCodeVerifier, readRedirectUriOverride, refreshAccessToken, startOAuthCallbackServer, } from './oauthUtils.js';
21
+ import { BrowserFeaturesUnavailableError, loadPlaywright } from './playwrightLoader.js';
22
+ import { BrowserDisabledError, BrowserFlowsNotSupportedError, CredentialFormFieldMissingError, CredentialFormValues, GraphicalEnvironmentNotFoundError, generateLatchkeyAppName, hasGraphicalEnvironment, requestCredentialsFromUser, showSpinnerPage, typeLikeHuman, withTempBrowserContext, } from './playwrightUtils.js';
23
+ import { BUILTIN_SERVICES } from './serviceRegistry.js';
24
+ import { BrowserFollowupServiceSession, DynamicClientPrepareInputSchema, FollowupWork, LoginCancelledError, LoginFailedError, NoCurlCredentialsNotSupportedError, PrepareInputInvalidError, PrepareNotSupportedError, RedirectUriOverrideSchema, Service, ServiceSession, SimpleServiceSession, buildDynamicClientPreparation, buildFollowupSpinnerDetails, buildPreparedCredentials, describeSchemaIssues, isBrowserClosedError, isResponseBodyUnavailableError, isTimeoutError, } from './services/core/base.js';
25
+ import { CookieCaptureLoginFlow } from './services/core/loginFlows/cookieCapture.js';
26
+ import { TokenCaptureLoginFlow } from './services/core/loginFlows/tokenCapture.js';
27
+ import { RegisteredService } from './services/core/registered.js';
28
+ import { GoogleService } from './services/google/base.js';
29
+ export function createLatchkeySdk(latchkeyVersion) {
30
+ return Object.freeze({
31
+ latchkeyVersion,
32
+ z,
33
+ builtinServices: BUILTIN_SERVICES,
34
+ // Services
35
+ Service,
36
+ ServiceSession,
37
+ SimpleServiceSession,
38
+ BrowserFollowupServiceSession,
39
+ FollowupWork,
40
+ RegisteredService,
41
+ GoogleService,
42
+ CookieCaptureLoginFlow,
43
+ TokenCaptureLoginFlow,
44
+ buildDynamicClientPreparation,
45
+ buildFollowupSpinnerDetails,
46
+ buildPreparedCredentials,
47
+ describeSchemaIssues,
48
+ isBrowserClosedError,
49
+ isResponseBodyUnavailableError,
50
+ isTimeoutError,
51
+ LoginCancelledError,
52
+ LoginFailedError,
53
+ NoCurlCredentialsNotSupportedError,
54
+ PrepareNotSupportedError,
55
+ PrepareInputInvalidError,
56
+ RedirectUriOverrideSchema,
57
+ DynamicClientPrepareInputSchema,
58
+ // Credentials
59
+ ApiCredentialStatus,
60
+ ApiCredentialsUsageError,
61
+ AuthorizationBearer,
62
+ AuthorizationBare,
63
+ RawCurlCredentials,
64
+ OAuthCredentials,
65
+ DEFAULT_ACCOUNT,
66
+ fetchAccountFromEndpoint,
67
+ tryParseJson,
68
+ // Browser automation
69
+ loadPlaywright,
70
+ withTempBrowserContext,
71
+ showSpinnerPage,
72
+ requestCredentialsFromUser,
73
+ typeLikeHuman,
74
+ generateLatchkeyAppName,
75
+ hasGraphicalEnvironment,
76
+ CredentialFormValues,
77
+ CredentialFormFieldMissingError,
78
+ BrowserDisabledError,
79
+ BrowserFlowsNotSupportedError,
80
+ BrowserFeaturesUnavailableError,
81
+ GraphicalEnvironmentNotFoundError,
82
+ // OAuth
83
+ startOAuthCallbackServer,
84
+ DEFAULT_OAUTH_CALLBACK_PATH,
85
+ buildLoopbackRedirectUri,
86
+ readRedirectUriOverride,
87
+ exchangeCodeForTokens,
88
+ refreshAccessToken,
89
+ generateCodeVerifier,
90
+ generateCodeChallenge,
91
+ OAuthTokenExchangeError,
92
+ OAuthCallbackServerTimeoutError,
93
+ // curl
94
+ runCurlCapturedAsync: runCapturedAsync,
95
+ });
96
+ }
97
+ //# sourceMappingURL=pluginSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginSdk.js","sourceRoot":"","sources":["../../src/pluginSdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,YAAY,GACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,GAC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B;QAChB,kCAAkC;QAClC,wBAAwB;QACxB,wBAAwB;QACxB,yBAAyB;QACzB,+BAA+B;QAE/B,cAAc;QACd,mBAAmB;QACnB,wBAAwB;QACxB,mBAAmB;QACnB,iBAAiB;QACjB,kBAAkB;QAClB,gBAAgB;QAChB,eAAe;QACf,wBAAwB;QACxB,YAAY;QAEZ,qBAAqB;QACrB,cAAc;QACd,sBAAsB;QACtB,eAAe;QACf,0BAA0B;QAC1B,aAAa;QACb,uBAAuB;QACvB,uBAAuB;QACvB,oBAAoB;QACpB,+BAA+B;QAC/B,oBAAoB;QACpB,6BAA6B;QAC7B,+BAA+B;QAC/B,iCAAiC;QAEjC,QAAQ;QACR,wBAAwB;QACxB,2BAA2B;QAC3B,wBAAwB;QACxB,uBAAuB;QACvB,qBAAqB;QACrB,kBAAkB;QAClB,oBAAoB;QACpB,qBAAqB;QACrB,uBAAuB;QACvB,+BAA+B;QAE/B,OAAO;QACP,oBAAoB,EAAE,gBAAgB;KACvC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Plugins: services contributed by repositories cloned into the plugins
3
+ * directory (`~/.latchkey/plugins/` by default). Once loaded, their services
4
+ * are indistinguishable from the built-in ones.
5
+ *
6
+ * A plugin is an ES module package whose default export is a factory. It is
7
+ * handed a {@link LatchkeySdk} and returns a {@link LatchkeyPlugin}:
8
+ *
9
+ * export default (sdk) => {
10
+ * class Foo extends sdk.Service { ... }
11
+ * return { latchkeyVersion: '^3.15.0', services: [new Foo()] };
12
+ * };
13
+ *
14
+ * A plugin whose services use a credentials class of their own also lists
15
+ * that class under `apiCredentialsTypes`, which is what lets such credentials
16
+ * be stored. The class carries a static `objectType` and a static `fromJSON`
17
+ * that validates stored data (see the built-in credentials classes).
18
+ *
19
+ * `latchkeyVersion` is the range of Latchkey versions the plugin was written
20
+ * for, in the syntax of a package.json dependency. Latchkey follows semantic
21
+ * versioning with respect to the sdk, so `^3.15.0` means "3.15.0 or newer,
22
+ * until the next major version", and a plugin whose range excludes the running
23
+ * Latchkey is refused at load time rather than failing in some subtler way
24
+ * later.
25
+ *
26
+ * Everything a plugin needs at runtime comes from the sdk, so a bare
27
+ * `git clone` into the plugins directory is a complete installation.
28
+ */
29
+ import type { ApiCredentialsType } from './apiCredentials/base.js';
30
+ import type { LatchkeySdk } from './pluginSdk.js';
31
+ import { Service } from './services/core/base.js';
32
+ export interface LatchkeyPlugin {
33
+ /**
34
+ * The Latchkey versions the plugin supports, as a package.json-style
35
+ * version range such as `^3.15.0`.
36
+ */
37
+ readonly latchkeyVersion: string;
38
+ readonly services: readonly Service[];
39
+ /** The credentials classes the plugin defines, if any. */
40
+ readonly apiCredentialsTypes?: readonly ApiCredentialsType[];
41
+ }
42
+ export type LatchkeyPluginFactory = (sdk: LatchkeySdk) => LatchkeyPlugin | Promise<LatchkeyPlugin>;
43
+ export interface LoadedPlugin {
44
+ /** The name of the plugin's directory inside the plugins directory. */
45
+ readonly name: string;
46
+ readonly directory: string;
47
+ readonly services: readonly Service[];
48
+ readonly apiCredentialsTypes: readonly ApiCredentialsType[];
49
+ }
50
+ export declare class PluginLoadError extends Error {
51
+ constructor(pluginName: string, detail: string);
52
+ }
53
+ /**
54
+ * Whether the running Latchkey falls within the version range a plugin
55
+ * declares. A prerelease Latchkey (say a development build) counts too, as
56
+ * long as the range would admit its release.
57
+ */
58
+ export declare function isLatchkeyVersionSupported(versionRange: string, latchkeyVersion: string): boolean;
59
+ /**
60
+ * Load every plugin found in `directory`, in alphabetical order of directory
61
+ * name. Entries that are not directories (following symlinks, so a checkout
62
+ * elsewhere can be linked in) are ignored, as are `node_modules` and dot
63
+ * directories. A missing directory means no plugins. Throws `PluginLoadError`
64
+ * on the first plugin that cannot be loaded.
65
+ */
66
+ export declare function loadPlugins(directory: string, sdk: LatchkeySdk): Promise<readonly LoadedPlugin[]>;
67
+ /**
68
+ * The built-in services followed by every plugin's, refusing a plugin service
69
+ * whose name is already taken. The registry itself only checks names as
70
+ * services are added one by one, and these all go in together.
71
+ */
72
+ export declare function combineWithPluginServices(builtinServices: readonly Service[], plugins: readonly LoadedPlugin[]): readonly Service[];
73
+ export declare function combineWithPluginApiCredentialsTypes(builtinTypes: readonly ApiCredentialsType[], plugins: readonly LoadedPlugin[]): readonly ApiCredentialsType[];
74
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAC9D;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEnG,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,mBAAmB,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAC7D;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI/C;AAuDD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAEjG;AAqID;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAclC;AA+BD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,SAAS,OAAO,EAAE,EACnC,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,SAAS,OAAO,EAAE,CAQpB;AAED,wBAAgB,oCAAoC,CAClD,YAAY,EAAE,SAAS,kBAAkB,EAAE,EAC3C,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,SAAS,kBAAkB,EAAE,CAQ/B"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Plugins: services contributed by repositories cloned into the plugins
3
+ * directory (`~/.latchkey/plugins/` by default). Once loaded, their services
4
+ * are indistinguishable from the built-in ones.
5
+ *
6
+ * A plugin is an ES module package whose default export is a factory. It is
7
+ * handed a {@link LatchkeySdk} and returns a {@link LatchkeyPlugin}:
8
+ *
9
+ * export default (sdk) => {
10
+ * class Foo extends sdk.Service { ... }
11
+ * return { latchkeyVersion: '^3.15.0', services: [new Foo()] };
12
+ * };
13
+ *
14
+ * A plugin whose services use a credentials class of their own also lists
15
+ * that class under `apiCredentialsTypes`, which is what lets such credentials
16
+ * be stored. The class carries a static `objectType` and a static `fromJSON`
17
+ * that validates stored data (see the built-in credentials classes).
18
+ *
19
+ * `latchkeyVersion` is the range of Latchkey versions the plugin was written
20
+ * for, in the syntax of a package.json dependency. Latchkey follows semantic
21
+ * versioning with respect to the sdk, so `^3.15.0` means "3.15.0 or newer,
22
+ * until the next major version", and a plugin whose range excludes the running
23
+ * Latchkey is refused at load time rather than failing in some subtler way
24
+ * later.
25
+ *
26
+ * Everything a plugin needs at runtime comes from the sdk, so a bare
27
+ * `git clone` into the plugins directory is a complete installation.
28
+ */
29
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
30
+ import { join } from 'node:path';
31
+ import { pathToFileURL } from 'node:url';
32
+ import { satisfies as satisfiesVersionRange, validRange } from 'semver';
33
+ import { Service } from './services/core/base.js';
34
+ export class PluginLoadError extends Error {
35
+ constructor(pluginName, detail) {
36
+ super(`Failed to load plugin '${pluginName}': ${detail}`);
37
+ this.name = 'PluginLoadError';
38
+ }
39
+ }
40
+ const PACKAGE_JSON_FILENAME = 'package.json';
41
+ const DEFAULT_ENTRY_FILENAME = 'index.js';
42
+ // ─── Loading ──────────────────────────────────────────────────────────────────
43
+ /**
44
+ * The entry a package.json `exports` field points at for the package root,
45
+ * or undefined when it names none that an `import` would pick.
46
+ */
47
+ function pickEntryFromExports(exportsField) {
48
+ if (typeof exportsField === 'string') {
49
+ return exportsField;
50
+ }
51
+ if (typeof exportsField !== 'object' || exportsField === null) {
52
+ return undefined;
53
+ }
54
+ const record = exportsField;
55
+ if ('.' in record) {
56
+ return pickEntryFromExports(record['.']);
57
+ }
58
+ return pickEntryFromExports(record.import ?? record.default);
59
+ }
60
+ function resolvePluginEntryFile(pluginName, pluginDirectory) {
61
+ const packageJsonPath = join(pluginDirectory, PACKAGE_JSON_FILENAME);
62
+ let entry = DEFAULT_ENTRY_FILENAME;
63
+ if (existsSync(packageJsonPath)) {
64
+ let packageJson;
65
+ try {
66
+ packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
67
+ }
68
+ catch (error) {
69
+ const message = error instanceof Error ? error.message : String(error);
70
+ throw new PluginLoadError(pluginName, `invalid ${PACKAGE_JSON_FILENAME}: ${message}`);
71
+ }
72
+ const { exports: exportsField, main } = packageJson;
73
+ entry = pickEntryFromExports(exportsField) ?? (typeof main === 'string' ? main : entry);
74
+ }
75
+ const entryFile = join(pluginDirectory, entry);
76
+ if (!existsSync(entryFile)) {
77
+ throw new PluginLoadError(pluginName, `entry file '${entryFile}' does not exist. ` +
78
+ 'If the plugin is written in TypeScript, it has to be built first.');
79
+ }
80
+ return entryFile;
81
+ }
82
+ const EXAMPLE_VERSION_RANGE = '^3.15.0';
83
+ /**
84
+ * Whether the running Latchkey falls within the version range a plugin
85
+ * declares. A prerelease Latchkey (say a development build) counts too, as
86
+ * long as the range would admit its release.
87
+ */
88
+ export function isLatchkeyVersionSupported(versionRange, latchkeyVersion) {
89
+ return satisfiesVersionRange(latchkeyVersion, versionRange, { includePrerelease: true });
90
+ }
91
+ function validatePluginManifest(pluginName, manifest, latchkeyVersion) {
92
+ if (typeof manifest !== 'object' || manifest === null) {
93
+ throw new PluginLoadError(pluginName, 'the plugin factory did not return an object.');
94
+ }
95
+ const { latchkeyVersion: versionRange, services, apiCredentialsTypes, } = manifest;
96
+ if (typeof versionRange !== 'string') {
97
+ throw new PluginLoadError(pluginName, "'latchkeyVersion' must be a string declaring the Latchkey versions the plugin supports, " +
98
+ `like '${EXAMPLE_VERSION_RANGE}'.`);
99
+ }
100
+ if (validRange(versionRange) === null) {
101
+ throw new PluginLoadError(pluginName, `'${versionRange}' is not a valid version range for 'latchkeyVersion'. ` +
102
+ `Use the syntax of a package.json dependency, like '${EXAMPLE_VERSION_RANGE}'.`);
103
+ }
104
+ if (!isLatchkeyVersionSupported(versionRange, latchkeyVersion)) {
105
+ throw new PluginLoadError(pluginName, `it supports Latchkey ${versionRange}, but this is Latchkey ${latchkeyVersion}.`);
106
+ }
107
+ if (!Array.isArray(services)) {
108
+ throw new PluginLoadError(pluginName, "'services' must be an array of Service instances.");
109
+ }
110
+ for (const service of services) {
111
+ if (!(service instanceof Service)) {
112
+ throw new PluginLoadError(pluginName, "every entry of 'services' must extend the Service class handed to the plugin " +
113
+ 'as sdk.Service. A service that looks right but is still refused usually extends ' +
114
+ 'the class of a separately installed latchkey instead.');
115
+ }
116
+ }
117
+ return {
118
+ latchkeyVersion: versionRange,
119
+ services: services,
120
+ apiCredentialsTypes: validateApiCredentialsTypes(pluginName, apiCredentialsTypes),
121
+ };
122
+ }
123
+ function isApiCredentialsType(value) {
124
+ if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
125
+ return false;
126
+ }
127
+ const { objectType, fromJSON } = value;
128
+ return typeof objectType === 'string' && typeof fromJSON === 'function';
129
+ }
130
+ function validateApiCredentialsTypes(pluginName, apiCredentialsTypes) {
131
+ if (apiCredentialsTypes === undefined) {
132
+ return [];
133
+ }
134
+ if (!Array.isArray(apiCredentialsTypes)) {
135
+ throw new PluginLoadError(pluginName, "'apiCredentialsTypes' must be an array when present.");
136
+ }
137
+ for (const type of apiCredentialsTypes) {
138
+ if (!isApiCredentialsType(type)) {
139
+ throw new PluginLoadError(pluginName, "every entry of 'apiCredentialsTypes' must be a credentials class with a static " +
140
+ "'objectType' and a static 'fromJSON'.");
141
+ }
142
+ }
143
+ return apiCredentialsTypes;
144
+ }
145
+ async function loadPlugin(pluginName, pluginDirectory, sdk) {
146
+ const entryFile = resolvePluginEntryFile(pluginName, pluginDirectory);
147
+ let importedModule;
148
+ try {
149
+ importedModule = (await import(pathToFileURL(entryFile).href));
150
+ }
151
+ catch (error) {
152
+ throw new PluginLoadError(pluginName, `could not import '${entryFile}': ${error instanceof Error ? error.message : String(error)}`);
153
+ }
154
+ const factory = importedModule.default;
155
+ if (typeof factory !== 'function') {
156
+ throw new PluginLoadError(pluginName, `'${entryFile}' must have a default export that is a function (sdk) => plugin.`);
157
+ }
158
+ let manifest;
159
+ try {
160
+ manifest = await factory(sdk);
161
+ }
162
+ catch (error) {
163
+ const message = error instanceof Error ? error.message : String(error);
164
+ throw new PluginLoadError(pluginName, `the plugin factory threw: ${message}`);
165
+ }
166
+ const { services, apiCredentialsTypes } = validatePluginManifest(pluginName, manifest, sdk.latchkeyVersion);
167
+ return { name: pluginName, directory: pluginDirectory, services, apiCredentialsTypes };
168
+ }
169
+ function isDirectory(path) {
170
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
171
+ }
172
+ /**
173
+ * Load every plugin found in `directory`, in alphabetical order of directory
174
+ * name. Entries that are not directories (following symlinks, so a checkout
175
+ * elsewhere can be linked in) are ignored, as are `node_modules` and dot
176
+ * directories. A missing directory means no plugins. Throws `PluginLoadError`
177
+ * on the first plugin that cannot be loaded.
178
+ */
179
+ export async function loadPlugins(directory, sdk) {
180
+ if (!isDirectory(directory)) {
181
+ return [];
182
+ }
183
+ const pluginNames = readdirSync(directory)
184
+ .filter((name) => !name.startsWith('.') && name !== 'node_modules')
185
+ .filter((name) => isDirectory(join(directory, name)))
186
+ .sort();
187
+ const plugins = [];
188
+ for (const pluginName of pluginNames) {
189
+ plugins.push(await loadPlugin(pluginName, join(directory, pluginName), sdk));
190
+ }
191
+ return plugins;
192
+ }
193
+ /**
194
+ * The built-in items followed by every plugin's, refusing a plugin item whose
195
+ * key is already taken.
196
+ */
197
+ function combineWithPluginContributions(kind, builtinItems, plugins, itemsOf, keyOf) {
198
+ const providers = new Map(builtinItems.map((item) => [keyOf(item), 'Latchkey itself']));
199
+ for (const plugin of plugins) {
200
+ for (const item of itemsOf(plugin)) {
201
+ const provider = providers.get(keyOf(item));
202
+ if (provider !== undefined) {
203
+ throw new PluginLoadError(plugin.name, `${kind} '${keyOf(item)}' is already provided by ${provider}.`);
204
+ }
205
+ providers.set(keyOf(item), `plugin '${plugin.name}'`);
206
+ }
207
+ }
208
+ return [...builtinItems, ...plugins.flatMap(itemsOf)];
209
+ }
210
+ /**
211
+ * The built-in services followed by every plugin's, refusing a plugin service
212
+ * whose name is already taken. The registry itself only checks names as
213
+ * services are added one by one, and these all go in together.
214
+ */
215
+ export function combineWithPluginServices(builtinServices, plugins) {
216
+ return combineWithPluginContributions('service', builtinServices, plugins, (plugin) => plugin.services, (service) => service.name);
217
+ }
218
+ export function combineWithPluginApiCredentialsTypes(builtinTypes, plugins) {
219
+ return combineWithPluginContributions('credentials type', builtinTypes, plugins, (plugin) => plugin.apiCredentialsTypes, (type) => type.objectType);
220
+ }
221
+ //# sourceMappingURL=plugins.js.map