@authsome/client 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authsome/client",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "TypeScript client for AuthSome authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -3,31 +3,31 @@
3
3
  import { ClientPlugin } from './plugin';
4
4
  import { createErrorFromResponse } from './errors';
5
5
  import * as types from './types';
6
- import { SsoPlugin } from './plugins/sso';
7
- import { TwofaPlugin } from './plugins/twofa';
8
- import { WebhookPlugin } from './plugins/webhook';
9
- import { AdminPlugin } from './plugins/admin';
10
- import { ApikeyPlugin } from './plugins/apikey';
11
- import { EmailotpPlugin } from './plugins/emailotp';
12
- import { BackupauthPlugin } from './plugins/backupauth';
13
- import { CompliancePlugin } from './plugins/compliance';
14
- import { ImpersonationPlugin } from './plugins/impersonation';
15
6
  import { MagiclinkPlugin } from './plugins/magiclink';
16
- import { MultiappPlugin } from './plugins/multiapp';
17
- import { AnonymousPlugin } from './plugins/anonymous';
18
- import { JwtPlugin } from './plugins/jwt';
19
- import { MfaPlugin } from './plugins/mfa';
20
- import { MultisessionPlugin } from './plugins/multisession';
21
7
  import { NotificationPlugin } from './plugins/notification';
22
- import { OidcproviderPlugin } from './plugins/oidcprovider';
23
- import { OrganizationPlugin } from './plugins/organization';
24
8
  import { PasskeyPlugin } from './plugins/passkey';
25
- import { SocialPlugin } from './plugins/social';
26
9
  import { UsernamePlugin } from './plugins/username';
10
+ import { ApikeyPlugin } from './plugins/apikey';
11
+ import { BackupauthPlugin } from './plugins/backupauth';
27
12
  import { ConsentPlugin } from './plugins/consent';
28
13
  import { IdverificationPlugin } from './plugins/idverification';
29
- import { StepupPlugin } from './plugins/stepup';
14
+ import { MultiappPlugin } from './plugins/multiapp';
15
+ import { OidcproviderPlugin } from './plugins/oidcprovider';
30
16
  import { PhonePlugin } from './plugins/phone';
17
+ import { AdminPlugin } from './plugins/admin';
18
+ import { EmailotpPlugin } from './plugins/emailotp';
19
+ import { MfaPlugin } from './plugins/mfa';
20
+ import { OrganizationPlugin } from './plugins/organization';
21
+ import { SocialPlugin } from './plugins/social';
22
+ import { SsoPlugin } from './plugins/sso';
23
+ import { AnonymousPlugin } from './plugins/anonymous';
24
+ import { StepupPlugin } from './plugins/stepup';
25
+ import { JwtPlugin } from './plugins/jwt';
26
+ import { MultisessionPlugin } from './plugins/multisession';
27
+ import { TwofaPlugin } from './plugins/twofa';
28
+ import { WebhookPlugin } from './plugins/webhook';
29
+ import { CompliancePlugin } from './plugins/compliance';
30
+ import { ImpersonationPlugin } from './plugins/impersonation';
31
31
 
32
32
  /**
33
33
  * AuthSome client configuration
@@ -126,36 +126,49 @@ export class AuthsomeClient {
126
126
  this.basePath = basePath;
127
127
  }
128
128
 
129
+ /**
130
+ * Set global headers for all requests
131
+ * @param headers - Headers to set
132
+ * @param replace - If true, replaces all existing headers. If false (default), merges with existing headers
133
+ */
134
+ setGlobalHeaders(headers: Record<string, string>, replace: boolean = false): void {
135
+ if (replace) {
136
+ this.headers = { ...headers };
137
+ } else {
138
+ this.headers = { ...this.headers, ...headers };
139
+ }
140
+ }
141
+
129
142
  getPlugin<T extends ClientPlugin>(id: string): T | undefined {
130
143
  return this.plugins.get(id) as T | undefined;
131
144
  }
132
145
 
133
146
  public readonly $plugins = {
134
- sso: (): SsoPlugin | undefined => this.getPlugin<SsoPlugin>('sso'),
135
- twofa: (): TwofaPlugin | undefined => this.getPlugin<TwofaPlugin>('twofa'),
136
- webhook: (): WebhookPlugin | undefined => this.getPlugin<WebhookPlugin>('webhook'),
137
- admin: (): AdminPlugin | undefined => this.getPlugin<AdminPlugin>('admin'),
138
- apikey: (): ApikeyPlugin | undefined => this.getPlugin<ApikeyPlugin>('apikey'),
139
- emailotp: (): EmailotpPlugin | undefined => this.getPlugin<EmailotpPlugin>('emailotp'),
140
- backupauth: (): BackupauthPlugin | undefined => this.getPlugin<BackupauthPlugin>('backupauth'),
141
- compliance: (): CompliancePlugin | undefined => this.getPlugin<CompliancePlugin>('compliance'),
142
- impersonation: (): ImpersonationPlugin | undefined => this.getPlugin<ImpersonationPlugin>('impersonation'),
143
147
  magiclink: (): MagiclinkPlugin | undefined => this.getPlugin<MagiclinkPlugin>('magiclink'),
144
- multiapp: (): MultiappPlugin | undefined => this.getPlugin<MultiappPlugin>('multiapp'),
145
- anonymous: (): AnonymousPlugin | undefined => this.getPlugin<AnonymousPlugin>('anonymous'),
146
- jwt: (): JwtPlugin | undefined => this.getPlugin<JwtPlugin>('jwt'),
147
- mfa: (): MfaPlugin | undefined => this.getPlugin<MfaPlugin>('mfa'),
148
- multisession: (): MultisessionPlugin | undefined => this.getPlugin<MultisessionPlugin>('multisession'),
149
148
  notification: (): NotificationPlugin | undefined => this.getPlugin<NotificationPlugin>('notification'),
150
- oidcprovider: (): OidcproviderPlugin | undefined => this.getPlugin<OidcproviderPlugin>('oidcprovider'),
151
- organization: (): OrganizationPlugin | undefined => this.getPlugin<OrganizationPlugin>('organization'),
152
149
  passkey: (): PasskeyPlugin | undefined => this.getPlugin<PasskeyPlugin>('passkey'),
153
- social: (): SocialPlugin | undefined => this.getPlugin<SocialPlugin>('social'),
154
150
  username: (): UsernamePlugin | undefined => this.getPlugin<UsernamePlugin>('username'),
151
+ apikey: (): ApikeyPlugin | undefined => this.getPlugin<ApikeyPlugin>('apikey'),
152
+ backupauth: (): BackupauthPlugin | undefined => this.getPlugin<BackupauthPlugin>('backupauth'),
155
153
  consent: (): ConsentPlugin | undefined => this.getPlugin<ConsentPlugin>('consent'),
156
154
  idverification: (): IdverificationPlugin | undefined => this.getPlugin<IdverificationPlugin>('idverification'),
157
- stepup: (): StepupPlugin | undefined => this.getPlugin<StepupPlugin>('stepup'),
155
+ multiapp: (): MultiappPlugin | undefined => this.getPlugin<MultiappPlugin>('multiapp'),
156
+ oidcprovider: (): OidcproviderPlugin | undefined => this.getPlugin<OidcproviderPlugin>('oidcprovider'),
158
157
  phone: (): PhonePlugin | undefined => this.getPlugin<PhonePlugin>('phone'),
158
+ admin: (): AdminPlugin | undefined => this.getPlugin<AdminPlugin>('admin'),
159
+ emailotp: (): EmailotpPlugin | undefined => this.getPlugin<EmailotpPlugin>('emailotp'),
160
+ mfa: (): MfaPlugin | undefined => this.getPlugin<MfaPlugin>('mfa'),
161
+ organization: (): OrganizationPlugin | undefined => this.getPlugin<OrganizationPlugin>('organization'),
162
+ social: (): SocialPlugin | undefined => this.getPlugin<SocialPlugin>('social'),
163
+ sso: (): SsoPlugin | undefined => this.getPlugin<SsoPlugin>('sso'),
164
+ anonymous: (): AnonymousPlugin | undefined => this.getPlugin<AnonymousPlugin>('anonymous'),
165
+ stepup: (): StepupPlugin | undefined => this.getPlugin<StepupPlugin>('stepup'),
166
+ jwt: (): JwtPlugin | undefined => this.getPlugin<JwtPlugin>('jwt'),
167
+ multisession: (): MultisessionPlugin | undefined => this.getPlugin<MultisessionPlugin>('multisession'),
168
+ twofa: (): TwofaPlugin | undefined => this.getPlugin<TwofaPlugin>('twofa'),
169
+ webhook: (): WebhookPlugin | undefined => this.getPlugin<WebhookPlugin>('webhook'),
170
+ compliance: (): CompliancePlugin | undefined => this.getPlugin<CompliancePlugin>('compliance'),
171
+ impersonation: (): ImpersonationPlugin | undefined => this.getPlugin<ImpersonationPlugin>('impersonation'),
159
172
  };
160
173
 
161
174
  public async request<T>(
@@ -210,9 +223,9 @@ export class AuthsomeClient {
210
223
  });
211
224
  }
212
225
 
213
- async signIn(request: { email: string; password: string }): Promise<{ session: types.Session; requiresTwoFactor: boolean; user: types.User }> {
226
+ async signIn(request: { email: string; password: string }): Promise<{ user: types.User; session: types.Session; requiresTwoFactor: boolean }> {
214
227
  const path = '/signin';
215
- return this.request<{ session: types.Session; requiresTwoFactor: boolean; user: types.User }>('POST', path, {
228
+ return this.request<{ user: types.User; session: types.Session; requiresTwoFactor: boolean }>('POST', path, {
216
229
  body: request,
217
230
  });
218
231
  }
@@ -231,7 +244,7 @@ export class AuthsomeClient {
231
244
  });
232
245
  }
233
246
 
234
- async updateUser(request: { name?: string; email?: string }): Promise<{ user: types.User }> {
247
+ async updateUser(request: { email?: string; name?: string }): Promise<{ user: types.User }> {
235
248
  const path = '/user/update';
236
249
  return this.request<{ user: types.User }>('POST', path, {
237
250
  body: request,
package/src/index.ts CHANGED
@@ -6,28 +6,28 @@ export * from './types';
6
6
  export * from './errors';
7
7
 
8
8
  // Plugin exports
9
- export { SsoPlugin, ssoClient } from './plugins/sso';
10
- export { TwofaPlugin, twofaClient } from './plugins/twofa';
11
- export { WebhookPlugin, webhookClient } from './plugins/webhook';
12
- export { AdminPlugin, adminClient } from './plugins/admin';
13
- export { ApikeyPlugin, apikeyClient } from './plugins/apikey';
14
- export { EmailotpPlugin, emailotpClient } from './plugins/emailotp';
15
- export { BackupauthPlugin, backupauthClient } from './plugins/backupauth';
16
- export { CompliancePlugin, complianceClient } from './plugins/compliance';
17
- export { ImpersonationPlugin, impersonationClient } from './plugins/impersonation';
18
9
  export { MagiclinkPlugin, magiclinkClient } from './plugins/magiclink';
19
- export { MultiappPlugin, multiappClient } from './plugins/multiapp';
20
- export { AnonymousPlugin, anonymousClient } from './plugins/anonymous';
21
- export { JwtPlugin, jwtClient } from './plugins/jwt';
22
- export { MfaPlugin, mfaClient } from './plugins/mfa';
23
- export { MultisessionPlugin, multisessionClient } from './plugins/multisession';
24
10
  export { NotificationPlugin, notificationClient } from './plugins/notification';
25
- export { OidcproviderPlugin, oidcproviderClient } from './plugins/oidcprovider';
26
- export { OrganizationPlugin, organizationClient } from './plugins/organization';
27
11
  export { PasskeyPlugin, passkeyClient } from './plugins/passkey';
28
- export { SocialPlugin, socialClient } from './plugins/social';
29
12
  export { UsernamePlugin, usernameClient } from './plugins/username';
13
+ export { ApikeyPlugin, apikeyClient } from './plugins/apikey';
14
+ export { BackupauthPlugin, backupauthClient } from './plugins/backupauth';
30
15
  export { ConsentPlugin, consentClient } from './plugins/consent';
31
16
  export { IdverificationPlugin, idverificationClient } from './plugins/idverification';
32
- export { StepupPlugin, stepupClient } from './plugins/stepup';
17
+ export { MultiappPlugin, multiappClient } from './plugins/multiapp';
18
+ export { OidcproviderPlugin, oidcproviderClient } from './plugins/oidcprovider';
33
19
  export { PhonePlugin, phoneClient } from './plugins/phone';
20
+ export { AdminPlugin, adminClient } from './plugins/admin';
21
+ export { EmailotpPlugin, emailotpClient } from './plugins/emailotp';
22
+ export { MfaPlugin, mfaClient } from './plugins/mfa';
23
+ export { OrganizationPlugin, organizationClient } from './plugins/organization';
24
+ export { SocialPlugin, socialClient } from './plugins/social';
25
+ export { SsoPlugin, ssoClient } from './plugins/sso';
26
+ export { AnonymousPlugin, anonymousClient } from './plugins/anonymous';
27
+ export { StepupPlugin, stepupClient } from './plugins/stepup';
28
+ export { JwtPlugin, jwtClient } from './plugins/jwt';
29
+ export { MultisessionPlugin, multisessionClient } from './plugins/multisession';
30
+ export { TwofaPlugin, twofaClient } from './plugins/twofa';
31
+ export { WebhookPlugin, webhookClient } from './plugins/webhook';
32
+ export { CompliancePlugin, complianceClient } from './plugins/compliance';
33
+ export { ImpersonationPlugin, impersonationClient } from './plugins/impersonation';
@@ -27,7 +27,7 @@ export class WebhookPlugin implements ClientPlugin {
27
27
  });
28
28
  }
29
29
 
30
- async update(request: { events?: string[]; enabled?: boolean; id: string; url?: string }): Promise<{ webhook: types.Webhook }> {
30
+ async update(request: { id: string; url?: string; events?: string[]; enabled?: boolean }): Promise<{ webhook: types.Webhook }> {
31
31
  const path = '/webhooks/update';
32
32
  return this.client.request<{ webhook: types.Webhook }>('POST', path, {
33
33
  body: request,