@kya-os/provider-registry 0.1.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/README.md +592 -0
- package/dist/default-providers.d.ts +30 -0
- package/dist/default-providers.d.ts.map +1 -0
- package/dist/default-providers.js +162 -0
- package/dist/default-providers.js.map +1 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +173 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +291 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +339 -0
- package/dist/registry.js.map +1 -0
- package/dist/schemas.d.ts +780 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +104 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +35 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYpC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBzC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE/B,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,GACX,kBAAkB,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAEtE"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry Zod Schemas
|
|
3
|
+
*
|
|
4
|
+
* Runtime validation schemas for provider definitions and configuration.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for OAuth provider configuration
|
|
9
|
+
*/
|
|
10
|
+
export const OAuthProviderConfigSchema = z.object({
|
|
11
|
+
authorizationEndpoint: z.string().url('Authorization endpoint must be a valid URL'),
|
|
12
|
+
tokenEndpoint: z.string().url('Token endpoint must be a valid URL'),
|
|
13
|
+
userInfoEndpoint: z.string().url().optional(),
|
|
14
|
+
defaultScopes: z.array(z.string()).optional(),
|
|
15
|
+
supportsPKCE: z.boolean().optional(),
|
|
16
|
+
requiresClientSecret: z.boolean().optional(),
|
|
17
|
+
tokenEndpointAuthMethod: z.enum(['client_secret_post', 'client_secret_basic']).optional(),
|
|
18
|
+
responseType: z.string().optional(),
|
|
19
|
+
grantType: z.string().optional(),
|
|
20
|
+
customParams: z.record(z.string()).optional(),
|
|
21
|
+
authUrlTemplate: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Zod schema for credential provider configuration
|
|
25
|
+
*/
|
|
26
|
+
export const CredentialProviderConfigSchema = z.object({
|
|
27
|
+
authEndpoint: z.string().url('Auth endpoint must be a valid URL'),
|
|
28
|
+
httpMethod: z.enum(['POST', 'PUT']).optional(),
|
|
29
|
+
contentType: z.enum(['application/json', 'application/x-www-form-urlencoded']).optional(),
|
|
30
|
+
requestBodyTemplate: z.object({
|
|
31
|
+
identityField: z.string().optional(),
|
|
32
|
+
passwordField: z.string().optional(),
|
|
33
|
+
additionalFields: z.record(z.string()).optional(),
|
|
34
|
+
}).optional(),
|
|
35
|
+
responseFields: z.object({
|
|
36
|
+
sessionTokenPath: z.string().optional(),
|
|
37
|
+
userIdPath: z.string().optional(),
|
|
38
|
+
userEmailPath: z.string().optional(),
|
|
39
|
+
userDisplayNamePath: z.string().optional(),
|
|
40
|
+
expiresInPath: z.string().optional(),
|
|
41
|
+
}).optional(),
|
|
42
|
+
successCheck: z.object({
|
|
43
|
+
path: z.string().optional(),
|
|
44
|
+
expectedValue: z.union([z.string(), z.boolean()]).optional(),
|
|
45
|
+
}).optional(),
|
|
46
|
+
useCookieSession: z.boolean().optional(),
|
|
47
|
+
cookieNames: z.string().optional(),
|
|
48
|
+
customHeaders: z.record(z.string()).optional(),
|
|
49
|
+
requiresCsrf: z.boolean().optional(),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Zod schema for ProviderDefinition
|
|
53
|
+
*/
|
|
54
|
+
export const ProviderDefinitionSchema = z.object({
|
|
55
|
+
id: z.string().min(1, 'Provider ID is required'),
|
|
56
|
+
displayName: z.string().optional(),
|
|
57
|
+
authType: z.enum([
|
|
58
|
+
'oauth2',
|
|
59
|
+
'password',
|
|
60
|
+
'verifiable_credential',
|
|
61
|
+
'passkey',
|
|
62
|
+
'magic_link',
|
|
63
|
+
'otp',
|
|
64
|
+
'none',
|
|
65
|
+
]),
|
|
66
|
+
oauthProviderId: z.string().optional(),
|
|
67
|
+
defaultScopes: z.array(z.string()).optional(),
|
|
68
|
+
oauthConfig: OAuthProviderConfigSchema.optional(),
|
|
69
|
+
credentialConfig: CredentialProviderConfigSchema.optional(),
|
|
70
|
+
ui: z
|
|
71
|
+
.object({
|
|
72
|
+
icon: z.string().optional(),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
})
|
|
75
|
+
.optional(),
|
|
76
|
+
metadata: z.record(z.unknown()).optional(),
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Zod schema for ProviderConfig (used for loadFromConfig)
|
|
80
|
+
*/
|
|
81
|
+
export const ProviderConfigSchema = z.object({
|
|
82
|
+
providers: z.array(ProviderDefinitionSchema),
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Validate a provider definition
|
|
86
|
+
*
|
|
87
|
+
* @param def - Provider definition to validate
|
|
88
|
+
* @returns Validated provider definition
|
|
89
|
+
* @throws ZodError if validation fails
|
|
90
|
+
*/
|
|
91
|
+
export function validateProviderDefinition(def) {
|
|
92
|
+
return ProviderDefinitionSchema.parse(def);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Validate provider configuration
|
|
96
|
+
*
|
|
97
|
+
* @param config - Configuration object to validate
|
|
98
|
+
* @returns Validated provider configuration
|
|
99
|
+
* @throws ZodError if validation fails
|
|
100
|
+
*/
|
|
101
|
+
export function validateProviderConfig(config) {
|
|
102
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CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC;CAC7C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAY;IAEZ,OAAO,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAe;IACpD,OAAO,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for provider registry system.
|
|
5
|
+
* This is the single source of truth for provider metadata and categorization.
|
|
6
|
+
*
|
|
7
|
+
* Architecture Note:
|
|
8
|
+
* - AuthMode is imported from @kya-os/contracts/consent for consistency with consent UI
|
|
9
|
+
* - ProviderAuthType is defined here (provider capabilities)
|
|
10
|
+
* - ConsentProviderType is defined here as a SUPERSET of what contracts defines
|
|
11
|
+
* (includes 'passkey' and 'verifiable_credential' which contracts doesn't have yet)
|
|
12
|
+
*
|
|
13
|
+
* Conceptual Model:
|
|
14
|
+
* - AuthMode: UI/flow level (what the consent page renders) - from @kya-os/consent via contracts
|
|
15
|
+
* - ProviderAuthType: what the provider supports / how it performs auth
|
|
16
|
+
* - ConsentProviderType: canonical provider_type posted by consent UI (backend routing)
|
|
17
|
+
*/
|
|
18
|
+
export { AUTH_MODES } from '@kya-os/contracts/consent';
|
|
19
|
+
export type { AuthMode } from '@kya-os/contracts/consent';
|
|
20
|
+
/**
|
|
21
|
+
* ConsentProviderType: canonical provider_type posted by the consent UI
|
|
22
|
+
*
|
|
23
|
+
* This is the vocabulary used by the consent service/server to route user submissions.
|
|
24
|
+
* NOTE: This is a superset of @kya-os/contracts CONSENT_PROVIDER_TYPES, adding
|
|
25
|
+
* 'passkey' and 'verifiable_credential' which will be added to contracts in a future version.
|
|
26
|
+
*/
|
|
27
|
+
export type ConsentProviderType = 'none' | 'credential' | 'password' | 'oauth2' | 'magic_link' | 'otp' | 'passkey' | 'verifiable_credential';
|
|
28
|
+
/**
|
|
29
|
+
* ProviderAuthType: what the provider supports / how it performs auth
|
|
30
|
+
*
|
|
31
|
+
* This is provider-registry specific vocabulary describing the provider's
|
|
32
|
+
* authentication capability.
|
|
33
|
+
*/
|
|
34
|
+
export declare const PROVIDER_AUTH_TYPES: {
|
|
35
|
+
readonly OAUTH2: "oauth2";
|
|
36
|
+
readonly PASSWORD: "password";
|
|
37
|
+
readonly VERIFIABLE_CREDENTIAL: "verifiable_credential";
|
|
38
|
+
readonly PASSKEY: "passkey";
|
|
39
|
+
readonly MAGIC_LINK: "magic_link";
|
|
40
|
+
readonly OTP: "otp";
|
|
41
|
+
readonly NONE: "none";
|
|
42
|
+
};
|
|
43
|
+
export type ProviderAuthType = (typeof PROVIDER_AUTH_TYPES)[keyof typeof PROVIDER_AUTH_TYPES];
|
|
44
|
+
/**
|
|
45
|
+
* OAuth Provider Configuration
|
|
46
|
+
*
|
|
47
|
+
* Runtime metadata for OAuth provider flows.
|
|
48
|
+
* NOTE: Do NOT store client secrets here. Use `metadata.clientSecretName`
|
|
49
|
+
* to reference secrets stored securely in environment/vault.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* oauthConfig: {
|
|
54
|
+
* authorizationEndpoint: 'https://github.com/login/oauth/authorize',
|
|
55
|
+
* tokenEndpoint: 'https://github.com/login/oauth/access_token',
|
|
56
|
+
* userInfoEndpoint: 'https://api.github.com/user',
|
|
57
|
+
* defaultScopes: ['read:user'],
|
|
58
|
+
* supportsPKCE: true,
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export interface OAuthProviderConfig {
|
|
63
|
+
/** OAuth authorization endpoint URL */
|
|
64
|
+
authorizationEndpoint: string;
|
|
65
|
+
/** OAuth token endpoint URL */
|
|
66
|
+
tokenEndpoint: string;
|
|
67
|
+
/** User info endpoint URL (for fetching user profile after auth) */
|
|
68
|
+
userInfoEndpoint?: string;
|
|
69
|
+
/** Default scopes to request if not specified elsewhere */
|
|
70
|
+
defaultScopes?: string[];
|
|
71
|
+
/** Whether this provider supports PKCE */
|
|
72
|
+
supportsPKCE?: boolean;
|
|
73
|
+
/** Whether client secret is required for token exchange */
|
|
74
|
+
requiresClientSecret?: boolean;
|
|
75
|
+
/** Token endpoint auth method */
|
|
76
|
+
tokenEndpointAuthMethod?: 'client_secret_post' | 'client_secret_basic';
|
|
77
|
+
/** OAuth response type (default: "code") */
|
|
78
|
+
responseType?: string;
|
|
79
|
+
/** OAuth grant type (default: "authorization_code") */
|
|
80
|
+
grantType?: string;
|
|
81
|
+
/** Custom OAuth parameters (e.g., audience, acr_values) */
|
|
82
|
+
customParams?: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* URL template with {placeholders} for dynamic values
|
|
85
|
+
* e.g., "https://{domain}/authorize" for Auth0
|
|
86
|
+
*/
|
|
87
|
+
authUrlTemplate?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Credential Provider Configuration
|
|
91
|
+
*
|
|
92
|
+
* Runtime metadata for credential/password authentication flows.
|
|
93
|
+
* Describes how to POST credentials and extract session data from response.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* credentialConfig: {
|
|
98
|
+
* authEndpoint: 'https://api.example.com/auth/login',
|
|
99
|
+
* httpMethod: 'POST',
|
|
100
|
+
* contentType: 'application/json',
|
|
101
|
+
* requestBodyTemplate: {
|
|
102
|
+
* identityField: 'email',
|
|
103
|
+
* passwordField: 'password',
|
|
104
|
+
* },
|
|
105
|
+
* responseFields: {
|
|
106
|
+
* sessionTokenPath: 'data.token',
|
|
107
|
+
* userIdPath: 'data.user.id',
|
|
108
|
+
* userEmailPath: 'data.user.email',
|
|
109
|
+
* },
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export interface CredentialProviderConfig {
|
|
114
|
+
/** Endpoint to POST credentials */
|
|
115
|
+
authEndpoint: string;
|
|
116
|
+
/** HTTP method (usually POST) */
|
|
117
|
+
httpMethod?: 'POST' | 'PUT';
|
|
118
|
+
/** Content type for request (default: application/json) */
|
|
119
|
+
contentType?: 'application/json' | 'application/x-www-form-urlencoded';
|
|
120
|
+
/** Request body field mapping */
|
|
121
|
+
requestBodyTemplate?: {
|
|
122
|
+
/** Field name for identity (email/username) in request body */
|
|
123
|
+
identityField?: string;
|
|
124
|
+
/** Field name for password in request body */
|
|
125
|
+
passwordField?: string;
|
|
126
|
+
/** Additional static fields to include in request */
|
|
127
|
+
additionalFields?: Record<string, string>;
|
|
128
|
+
};
|
|
129
|
+
/** Response field extraction paths (JSON path notation) */
|
|
130
|
+
responseFields?: {
|
|
131
|
+
/** Path to session token in response (e.g., "data.token") */
|
|
132
|
+
sessionTokenPath?: string;
|
|
133
|
+
/** Path to user ID in response */
|
|
134
|
+
userIdPath?: string;
|
|
135
|
+
/** Path to user email in response */
|
|
136
|
+
userEmailPath?: string;
|
|
137
|
+
/** Path to display name in response */
|
|
138
|
+
userDisplayNamePath?: string;
|
|
139
|
+
/** Path to token expiry in response */
|
|
140
|
+
expiresInPath?: string;
|
|
141
|
+
};
|
|
142
|
+
/** Success validation configuration */
|
|
143
|
+
successCheck?: {
|
|
144
|
+
/** JSON path to check for success */
|
|
145
|
+
path?: string;
|
|
146
|
+
/** Expected value at path */
|
|
147
|
+
expectedValue?: string | boolean;
|
|
148
|
+
};
|
|
149
|
+
/** Whether to use cookies for session (vs token in body) */
|
|
150
|
+
useCookieSession?: boolean;
|
|
151
|
+
/** Cookie name(s) to extract (semicolon-separated if multiple) */
|
|
152
|
+
cookieNames?: string;
|
|
153
|
+
/** Custom headers to include in auth request */
|
|
154
|
+
customHeaders?: Record<string, string>;
|
|
155
|
+
/** Whether CSRF token is required */
|
|
156
|
+
requiresCsrf?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Provider metadata definition
|
|
160
|
+
*
|
|
161
|
+
* Represents a single authentication provider with all its metadata.
|
|
162
|
+
* The authType field describes the provider's capability (how it performs auth).
|
|
163
|
+
*
|
|
164
|
+
* SECURITY NOTE: Never store actual secrets (client_secret, API keys) in
|
|
165
|
+
* provider definitions. Instead, use `metadata.clientSecretName` or similar
|
|
166
|
+
* to reference secrets stored in secure storage (env vars, Cloudflare secrets,
|
|
167
|
+
* vault, etc.). The agent reads secrets at runtime from secure storage.
|
|
168
|
+
*/
|
|
169
|
+
export interface ProviderDefinition {
|
|
170
|
+
/** Unique provider identifier (e.g., 'github', 'google', 'my-company-auth') */
|
|
171
|
+
id: string;
|
|
172
|
+
/** Human-friendly display name */
|
|
173
|
+
displayName?: string;
|
|
174
|
+
/** Provider's authentication capability (required) */
|
|
175
|
+
authType: ProviderAuthType;
|
|
176
|
+
/** Canonical OAuth provider ID (if authType === 'oauth2') */
|
|
177
|
+
oauthProviderId?: string;
|
|
178
|
+
/** Default OAuth scopes recommended for this provider */
|
|
179
|
+
defaultScopes?: string[];
|
|
180
|
+
/**
|
|
181
|
+
* OAuth provider configuration (for authType === 'oauth2')
|
|
182
|
+
* Contains endpoint URLs, PKCE support, etc.
|
|
183
|
+
*/
|
|
184
|
+
oauthConfig?: OAuthProviderConfig;
|
|
185
|
+
/**
|
|
186
|
+
* Credential provider configuration (for authType === 'password')
|
|
187
|
+
* Contains auth endpoint, request/response field mapping, etc.
|
|
188
|
+
*/
|
|
189
|
+
credentialConfig?: CredentialProviderConfig;
|
|
190
|
+
/** UI hints for consent page rendering */
|
|
191
|
+
ui?: {
|
|
192
|
+
/** Icon identifier or URL */
|
|
193
|
+
icon?: string;
|
|
194
|
+
/** Provider description */
|
|
195
|
+
description?: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Extra vendor or connector-specific metadata
|
|
199
|
+
*
|
|
200
|
+
* Use this for:
|
|
201
|
+
* - Secret references: `{ clientSecretName: 'GITHUB_CLIENT_SECRET' }`
|
|
202
|
+
* - Provider-specific settings not covered by oauthConfig/credentialConfig
|
|
203
|
+
*
|
|
204
|
+
* IMPORTANT: Do NOT store actual secrets here. Only store secret names/refs.
|
|
205
|
+
*/
|
|
206
|
+
metadata?: Record<string, unknown>;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Provider configuration schema (for loading from JSON/config)
|
|
210
|
+
*/
|
|
211
|
+
export interface ProviderConfig {
|
|
212
|
+
providers: ProviderDefinition[];
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,KAAK,GACL,SAAS,GACT,uBAAuB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CAQtB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,qBAAqB,EAAE,MAAM,CAAC;IAE9B,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IAEtB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAA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1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for provider registry system.
|
|
5
|
+
* This is the single source of truth for provider metadata and categorization.
|
|
6
|
+
*
|
|
7
|
+
* Architecture Note:
|
|
8
|
+
* - AuthMode is imported from @kya-os/contracts/consent for consistency with consent UI
|
|
9
|
+
* - ProviderAuthType is defined here (provider capabilities)
|
|
10
|
+
* - ConsentProviderType is defined here as a SUPERSET of what contracts defines
|
|
11
|
+
* (includes 'passkey' and 'verifiable_credential' which contracts doesn't have yet)
|
|
12
|
+
*
|
|
13
|
+
* Conceptual Model:
|
|
14
|
+
* - AuthMode: UI/flow level (what the consent page renders) - from @kya-os/consent via contracts
|
|
15
|
+
* - ProviderAuthType: what the provider supports / how it performs auth
|
|
16
|
+
* - ConsentProviderType: canonical provider_type posted by consent UI (backend routing)
|
|
17
|
+
*/
|
|
18
|
+
// Re-export canonical types from contracts for convenience
|
|
19
|
+
export { AUTH_MODES } from '@kya-os/contracts/consent';
|
|
20
|
+
/**
|
|
21
|
+
* ProviderAuthType: what the provider supports / how it performs auth
|
|
22
|
+
*
|
|
23
|
+
* This is provider-registry specific vocabulary describing the provider's
|
|
24
|
+
* authentication capability.
|
|
25
|
+
*/
|
|
26
|
+
export const PROVIDER_AUTH_TYPES = {
|
|
27
|
+
OAUTH2: 'oauth2',
|
|
28
|
+
PASSWORD: 'password', // username/password, credential form
|
|
29
|
+
VERIFIABLE_CREDENTIAL: 'verifiable_credential',
|
|
30
|
+
PASSKEY: 'passkey',
|
|
31
|
+
MAGIC_LINK: 'magic_link',
|
|
32
|
+
OTP: 'otp',
|
|
33
|
+
NONE: 'none',
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2DAA2D;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAoBvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU,EAAE,qCAAqC;IAC3D,qBAAqB,EAAE,uBAAuB;IAC9C,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kya-os/provider-registry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Single source of truth for provider definitions and provider-type mapping",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.build.json",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:coverage": "vitest run --coverage",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"lint": "eslint .",
|
|
19
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
20
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
21
|
+
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@kya-os/contracts": "^1.7.6",
|
|
26
|
+
"zod": "^3.25.76"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.14.9",
|
|
30
|
+
"@vitest/coverage-v8": "^4.0.5",
|
|
31
|
+
"eslint": "^8.57.0",
|
|
32
|
+
"typescript": "^5.5.3",
|
|
33
|
+
"vitest": "^4.0.5"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"package.json",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|