@managemint-solutions/sdk 0.6.0 → 0.7.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 CHANGED
@@ -15,7 +15,9 @@ are peer dependencies — the request DTOs (`AddStatusDto`, `UpdateStatusDto`, `
15
15
  `AdditionalDetailsIdDto`, `GetAdditionalDetailsDto`, `AddNoteDto`, `NoteIdDto`,
16
16
  `GetNotesDto`, `SupportingFileIdDto`, `GetSupportingFilesDto`, `GetClientsDto`, `ClientIdDto`,
17
17
  `CreateClientDto`, `UpdateClientDto`, `GetProjectsDto`, `ProjectIdDto`, `CreateProjectDto`,
18
- `UpdateProjectDto`, `GetTasksDto`, `TaskIdDto`, `CreateTaskDto`, `UpdateTaskDto`) ship with their class-validator
18
+ `UpdateProjectDto`, `GetTasksDto`, `TaskIdDto`, `CreateTaskDto`, `UpdateTaskDto`, `SignInDto`,
19
+ `ExchangeRefreshTokenDto`, `SendPasswordResetEmailDto`, `ExchangeTokenHashDto`,
20
+ `ResetPasswordDto`) ship with their class-validator
19
21
  decorators so consumers validate against
20
22
  the same rules the SDK's input types describe. `@nestjs/common` (^11) is an optional peer
21
23
  dependency, needed only for the `@managemint-solutions/sdk/nest` subpath.
@@ -196,13 +198,57 @@ The client decodes `{ mms_id, organization_id }` from the JWT itself and scopes
196
198
  by `organization_id`. `supabase.supabase` is the raw `@supabase/supabase-js` client
197
199
  (`TypedSupabaseClient`) — the escape hatch for queries not yet covered by a resource.
198
200
 
201
+ ## Auth
202
+
203
+ `SupabaseClient` needs the caller's JWT, which the auth flows are there to produce — so sign-in,
204
+ refresh and the password-reset exchanges live on a separate `SupabaseAuthClient`, built from the
205
+ publishable key alone.
206
+
207
+ ```ts
208
+ import { createSupabaseAuthClient } from '@managemint-solutions/sdk';
209
+
210
+ const auth = createSupabaseAuthClient({
211
+ url: process.env.SUPABASE_URL!,
212
+ key: process.env.SUPABASE_PUBLISHABLE_KEY!, // no caller token — these callers are logged out
213
+ });
214
+
215
+ const { access_token, refresh_token } = await auth.signIn({ email, password });
216
+ await auth.refreshSession({ refresh_token });
217
+ await auth.signOut();
218
+
219
+ // The redirect URL is passed in; the SDK reads no environment variables.
220
+ await auth.sendPasswordResetEmail({ email }, `${process.env.FRONTEND_URL}/reset-password`);
221
+ await auth.exchangeRecoveryToken({ token_hash }); // recovery link → tokens
222
+ await auth.exchangeConfirmToken({ token_hash }); // signup confirmation link → tokens
223
+ await auth.resetPassword({ password, access_token, refresh_token });
224
+ ```
225
+
226
+ `signIn` also stamps `users.last_logged_in` for the user who just signed in, on a throwaway
227
+ client carrying the fresh access token; a failed stamp never fails the login. `signOut` is a
228
+ no-op server-side — the client holds no session — and is kept for parity with the api endpoint
229
+ it replaces. `auth.supabase` is the raw `@supabase/supabase-js` client.
230
+
231
+ ```ts
232
+ import { SupabasePublicClient } from '@managemint-solutions/sdk/nest';
233
+ import { SignInDto, SupabaseAuthClient } from '@managemint-solutions/sdk';
234
+
235
+ @Controller('auth')
236
+ export class AuthController {
237
+ @Post('sign-in')
238
+ signIn(@SupabasePublicClient() auth: SupabaseAuthClient, @Body() body: SignInDto) {
239
+ return auth.signIn(body);
240
+ }
241
+ }
242
+ ```
243
+
199
244
  ## Errors
200
245
 
201
246
  Every error the SDK throws is a `SupabaseClientError` carrying the HTTP `status` to respond
202
247
  with and the client-facing body, `toResponse()` → `{ error, message }`. Postgrest/Postgres
203
248
  errors are translated by `mapPostgrestError` (Postgrest code → status, RLS permission and
204
249
  module denials → readable messages), Storage errors by `mapStorageError` (the storage error's
205
- own HTTP status, or 500 when it has none); JWT problems are `401 Authentication Error`. Consumers
250
+ own HTTP status, or 500 when it has none), Supabase Auth errors by `mapAuthError` (same rule,
251
+ `Authentication Error`); JWT problems are `401 Authentication Error`. Consumers
206
252
  return these as-is instead of mapping database errors themselves.
207
253
 
208
254
  ## NestJS
@@ -0,0 +1,19 @@
1
+ import type { ExchangeRefreshTokenDto as ExchangeRefreshTokenDtoType, ExchangeTokenHashDto as ExchangeTokenHashDtoType, loginDto as LoginDtoType, ResetPasswordDto as ResetPasswordDtoType, SendPasswordResetEmailDto as SendPasswordResetEmailDtoType } from '@managemint-solutions/entities/auth/dto';
2
+ export declare class SignInDto implements LoginDtoType {
3
+ readonly email: string;
4
+ readonly password: string;
5
+ }
6
+ export declare class ExchangeRefreshTokenDto implements ExchangeRefreshTokenDtoType {
7
+ readonly refresh_token: string;
8
+ }
9
+ export declare class SendPasswordResetEmailDto implements SendPasswordResetEmailDtoType {
10
+ readonly email: string;
11
+ }
12
+ export declare class ExchangeTokenHashDto implements ExchangeTokenHashDtoType {
13
+ readonly token_hash: string;
14
+ }
15
+ export declare class ResetPasswordDto implements ResetPasswordDtoType {
16
+ readonly password: string;
17
+ readonly access_token: string;
18
+ readonly refresh_token: string;
19
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResetPasswordDto = exports.ExchangeTokenHashDto = exports.SendPasswordResetEmailDto = exports.ExchangeRefreshTokenDto = exports.SignInDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ // class-validator versions of the shared DTO types from @managemint-solutions/entities.
15
+ // Each class `implements` its entities type so the wire contract cannot drift.
16
+ // The entities type is spelled `loginDto` (lowercase); the class keeps the `SignInDto` name.
17
+ class SignInDto {
18
+ email;
19
+ password;
20
+ }
21
+ exports.SignInDto = SignInDto;
22
+ __decorate([
23
+ (0, class_validator_1.IsEmail)({}, { message: 'Email is required' }),
24
+ __metadata("design:type", String)
25
+ ], SignInDto.prototype, "email", void 0);
26
+ __decorate([
27
+ (0, class_validator_1.IsString)({ message: 'Password is required' }),
28
+ __metadata("design:type", String)
29
+ ], SignInDto.prototype, "password", void 0);
30
+ class ExchangeRefreshTokenDto {
31
+ refresh_token;
32
+ }
33
+ exports.ExchangeRefreshTokenDto = ExchangeRefreshTokenDto;
34
+ __decorate([
35
+ (0, class_validator_1.IsString)({ message: 'Refresh token is required' }),
36
+ __metadata("design:type", String)
37
+ ], ExchangeRefreshTokenDto.prototype, "refresh_token", void 0);
38
+ class SendPasswordResetEmailDto {
39
+ email;
40
+ }
41
+ exports.SendPasswordResetEmailDto = SendPasswordResetEmailDto;
42
+ __decorate([
43
+ (0, class_validator_1.IsEmail)({}, { message: 'Email is required' }),
44
+ __metadata("design:type", String)
45
+ ], SendPasswordResetEmailDto.prototype, "email", void 0);
46
+ class ExchangeTokenHashDto {
47
+ token_hash;
48
+ }
49
+ exports.ExchangeTokenHashDto = ExchangeTokenHashDto;
50
+ __decorate([
51
+ (0, class_validator_1.IsString)({ message: 'Token hash is required' }),
52
+ __metadata("design:type", String)
53
+ ], ExchangeTokenHashDto.prototype, "token_hash", void 0);
54
+ class ResetPasswordDto {
55
+ password;
56
+ access_token;
57
+ refresh_token;
58
+ }
59
+ exports.ResetPasswordDto = ResetPasswordDto;
60
+ __decorate([
61
+ (0, class_validator_1.IsString)({ message: 'Password is required' }),
62
+ __metadata("design:type", String)
63
+ ], ResetPasswordDto.prototype, "password", void 0);
64
+ __decorate([
65
+ (0, class_validator_1.IsString)({ message: 'Access token is required' }),
66
+ __metadata("design:type", String)
67
+ ], ResetPasswordDto.prototype, "access_token", void 0);
68
+ __decorate([
69
+ (0, class_validator_1.IsString)({ message: 'Refresh token is required' }),
70
+ __metadata("design:type", String)
71
+ ], ResetPasswordDto.prototype, "refresh_token", void 0);
72
+ //# sourceMappingURL=dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/auth-client/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AASpD,wFAAwF;AACxF,+EAA+E;AAE/E,6FAA6F;AAC7F,MAAa,SAAS;IAEX,KAAK,CAAU;IAGf,QAAQ,CAAU;CAC5B;AAND,8BAMC;AAJU;IADR,IAAA,yBAAO,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;;wCACtB;AAGf;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;;2CACnB;AAG7B,MAAa,uBAAuB;IAEzB,aAAa,CAAU;CACjC;AAHD,0DAGC;AADU;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;;8DACnB;AAGlC,MAAa,yBAAyB;IAE3B,KAAK,CAAU;CACzB;AAHD,8DAGC;AADU;IADR,IAAA,yBAAO,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;;wDACtB;AAG1B,MAAa,oBAAoB;IAEtB,UAAU,CAAU;CAC9B;AAHD,oDAGC;AADU;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;;wDACnB;AAG/B,MAAa,gBAAgB;IAElB,QAAQ,CAAU;IAGlB,YAAY,CAAU;IAGtB,aAAa,CAAU;CACjC;AATD,4CASC;AAPU;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;;kDACnB;AAGlB;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;;sDACnB;AAGtB;IADR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;;uDACnB"}
@@ -0,0 +1,38 @@
1
+ import { type SupabaseClient as SupabaseJsClient } from '@supabase/supabase-js';
2
+ import type { ExchangeTokenResponse, LoginResponse } from '@managemint-solutions/entities/auth';
3
+ import type { ExchangeRefreshTokenDto, ExchangeTokenHashDto, loginDto, ResetPasswordDto, SendPasswordResetEmailDto } from '@managemint-solutions/entities/auth/dto';
4
+ export * from './dto';
5
+ export type SupabaseAuthClientConfig = {
6
+ url: string;
7
+ key: string;
8
+ };
9
+ /**
10
+ * The auth flows, for callers that do not have a JWT yet. `SupabaseClient` needs the caller's
11
+ * token to build its RLS context, so sign-in, refresh and the password-reset exchanges live on
12
+ * this separate client, built from the publishable key alone.
13
+ */
14
+ export declare class SupabaseAuthClient {
15
+ private readonly config;
16
+ readonly supabase: SupabaseJsClient;
17
+ constructor(config: SupabaseAuthClientConfig);
18
+ signIn(input: loginDto): Promise<LoginResponse>;
19
+ refreshSession(input: ExchangeRefreshTokenDto): Promise<ExchangeTokenResponse>;
20
+ /**
21
+ * Parity with the api: this client never holds a session (`persistSession` is off), so
22
+ * server-side there is nothing to revoke and the call is a no-op. Kept as the api had it.
23
+ */
24
+ signOut(): Promise<void>;
25
+ /** `redirectTo` is passed in — the SDK reads no environment variables. */
26
+ sendPasswordResetEmail(input: SendPasswordResetEmailDto, redirectTo: string): Promise<void>;
27
+ exchangeRecoveryToken(input: ExchangeTokenHashDto): Promise<ExchangeTokenResponse>;
28
+ exchangeConfirmToken(input: ExchangeTokenHashDto): Promise<ExchangeTokenResponse>;
29
+ resetPassword(input: ResetPasswordDto): Promise<void>;
30
+ /**
31
+ * Stamps `users.last_logged_in` as the user who just signed in — the users UPDATE policy
32
+ * allows `auth.uid() = mms_id`, so the write goes through a throwaway client carrying the
33
+ * fresh access token rather than this session-less one. Parity with the api: the result is
34
+ * ignored, a failed stamp must not fail the login.
35
+ */
36
+ private stampLastLoggedIn;
37
+ }
38
+ export declare const createSupabaseAuthClient: (config: SupabaseAuthClientConfig) => SupabaseAuthClient;
@@ -0,0 +1,135 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createSupabaseAuthClient = exports.SupabaseAuthClient = void 0;
18
+ const supabase_js_1 = require("@supabase/supabase-js");
19
+ const errors_1 = require("../errors");
20
+ __exportStar(require("./dto"), exports);
21
+ // The api's "no session/user returned" NotFoundException, as an SDK error.
22
+ const noSession = (message) => new errors_1.SupabaseClientError({ status: 404, error: 'Authentication Error', message });
23
+ const toTokens = (session) => ({
24
+ access_token: session.access_token,
25
+ refresh_token: session.refresh_token,
26
+ });
27
+ /**
28
+ * The auth flows, for callers that do not have a JWT yet. `SupabaseClient` needs the caller's
29
+ * token to build its RLS context, so sign-in, refresh and the password-reset exchanges live on
30
+ * this separate client, built from the publishable key alone.
31
+ */
32
+ class SupabaseAuthClient {
33
+ config;
34
+ supabase; // escape hatch for flows not covered by a method
35
+ constructor(config) {
36
+ this.config = config;
37
+ this.supabase = (0, supabase_js_1.createClient)(config.url, config.key, {
38
+ // Server-side and stateless: nothing is stored, refreshed or read out of a URL.
39
+ auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
40
+ });
41
+ }
42
+ async signIn(input) {
43
+ const { data, error } = await this.supabase.auth.signInWithPassword({
44
+ email: input.email,
45
+ password: input.password,
46
+ });
47
+ if (error)
48
+ throw (0, errors_1.mapAuthError)(error);
49
+ if (!data.session || !data.user) {
50
+ throw noSession('Authentication failed: No session or user data returned');
51
+ }
52
+ await this.stampLastLoggedIn(data.session.access_token, data.user.id);
53
+ return toTokens(data.session);
54
+ }
55
+ async refreshSession(input) {
56
+ const { data, error } = await this.supabase.auth.refreshSession({
57
+ refresh_token: input.refresh_token,
58
+ });
59
+ if (error)
60
+ throw (0, errors_1.mapAuthError)(error);
61
+ if (!data.session)
62
+ throw noSession('Token exchange failed: No session data returned');
63
+ return toTokens(data.session);
64
+ }
65
+ /**
66
+ * Parity with the api: this client never holds a session (`persistSession` is off), so
67
+ * server-side there is nothing to revoke and the call is a no-op. Kept as the api had it.
68
+ */
69
+ async signOut() {
70
+ const { error } = await this.supabase.auth.signOut();
71
+ if (error)
72
+ throw (0, errors_1.mapAuthError)(error);
73
+ }
74
+ /** `redirectTo` is passed in — the SDK reads no environment variables. */
75
+ async sendPasswordResetEmail(input, redirectTo) {
76
+ const { error } = await this.supabase.auth.resetPasswordForEmail(input.email, { redirectTo });
77
+ if (error)
78
+ throw (0, errors_1.mapAuthError)(error);
79
+ }
80
+ async exchangeRecoveryToken(input) {
81
+ const { data, error } = await this.supabase.auth.verifyOtp({
82
+ type: 'recovery',
83
+ token_hash: input.token_hash,
84
+ });
85
+ if (error)
86
+ throw (0, errors_1.mapAuthError)(error);
87
+ if (!data.session)
88
+ throw noSession('Token exchange failed: No session data returned');
89
+ return toTokens(data.session);
90
+ }
91
+ async exchangeConfirmToken(input) {
92
+ const { data, error } = await this.supabase.auth.verifyOtp({
93
+ type: 'signup',
94
+ token_hash: input.token_hash,
95
+ });
96
+ if (error)
97
+ throw (0, errors_1.mapAuthError)(error);
98
+ if (!data.session)
99
+ throw noSession('Token exchange failed: No session data returned');
100
+ return toTokens(data.session);
101
+ }
102
+ async resetPassword(input) {
103
+ const { error: sessionError } = await this.supabase.auth.setSession({
104
+ access_token: input.access_token,
105
+ refresh_token: input.refresh_token,
106
+ });
107
+ if (sessionError)
108
+ throw (0, errors_1.mapAuthError)(sessionError);
109
+ const { error: updateError } = await this.supabase.auth.updateUser({
110
+ password: input.password,
111
+ });
112
+ if (updateError)
113
+ throw (0, errors_1.mapAuthError)(updateError);
114
+ }
115
+ /**
116
+ * Stamps `users.last_logged_in` as the user who just signed in — the users UPDATE policy
117
+ * allows `auth.uid() = mms_id`, so the write goes through a throwaway client carrying the
118
+ * fresh access token rather than this session-less one. Parity with the api: the result is
119
+ * ignored, a failed stamp must not fail the login.
120
+ */
121
+ async stampLastLoggedIn(accessToken, userId) {
122
+ const asUser = (0, supabase_js_1.createClient)(this.config.url, this.config.key, {
123
+ global: { headers: { Authorization: `Bearer ${accessToken}` } },
124
+ auth: { persistSession: false, autoRefreshToken: false },
125
+ });
126
+ await asUser
127
+ .from('users')
128
+ .update({ last_logged_in: new Date().toISOString() })
129
+ .eq('mms_id', userId);
130
+ }
131
+ }
132
+ exports.SupabaseAuthClient = SupabaseAuthClient;
133
+ const createSupabaseAuthClient = (config) => new SupabaseAuthClient(config);
134
+ exports.createSupabaseAuthClient = createSupabaseAuthClient;
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth-client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAA8F;AAY9F,sCAA8D;AAE9D,wCAAsB;AAOtB,2EAA2E;AAC3E,MAAM,SAAS,GAAG,CAAC,OAAe,EAAuB,EAAE,CACzD,IAAI,4BAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,CAAC,CAAC;AAEnF,MAAM,QAAQ,GAAG,CAAC,OAGjB,EAAyB,EAAE,CAAC,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;IAClC,aAAa,EAAE,OAAO,CAAC,aAAa;CACrC,CAAC,CAAC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,MAAM;aACT,IAAI,CAAC,OAAO,CAAC;aACb,MAAM,CAAC,EAAE,cAAc,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;aACpD,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;CACF;AAxGD,gDAwGC;AAEM,MAAM,wBAAwB,GAAG,CAAC,MAAgC,EAAsB,EAAE,CAC/F,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AADpB,QAAA,wBAAwB,4BACJ"}
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { StorageError } from '@supabase/storage-js';
2
- import type { PostgrestError } from '@supabase/supabase-js';
2
+ import type { AuthError, PostgrestError } from '@supabase/supabase-js';
3
3
  export type SupabaseClientErrorInit = {
4
4
  /** HTTP status the consumer should respond with. */
5
5
  status: number;
@@ -34,3 +34,9 @@ export declare const mapPostgrestError: (error: PostgrestError) => SupabaseClien
34
34
  * network/unknown failures have none, hence the 500 fallback.
35
35
  */
36
36
  export declare const mapStorageError: (error: StorageError, message?: string) => SupabaseClientError;
37
+ /**
38
+ * Converts a Supabase Auth (GoTrue) error into the SupabaseClientError the SDK throws — the
39
+ * SDK-side equivalent of the api's `throwAuthErrorResponse`. `AuthError.status` is the HTTP
40
+ * status GoTrue answered with; network/unknown failures carry none, hence the 500 fallback.
41
+ */
42
+ export declare const mapAuthError: (error: AuthError) => SupabaseClientError;
package/dist/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapStorageError = exports.mapPostgrestError = exports.SupabaseClientError = void 0;
3
+ exports.mapAuthError = exports.mapStorageError = exports.mapPostgrestError = exports.SupabaseClientError = void 0;
4
4
  /**
5
5
  * Every error the SDK throws. It already carries the HTTP status and the body the
6
6
  * consumer sends back to the client (`toResponse()`), so the api needs no mapping.
@@ -140,4 +140,15 @@ const mapStorageError = (error, message = error.message) => new SupabaseClientEr
140
140
  message,
141
141
  }, { cause: error });
142
142
  exports.mapStorageError = mapStorageError;
143
+ /**
144
+ * Converts a Supabase Auth (GoTrue) error into the SupabaseClientError the SDK throws — the
145
+ * SDK-side equivalent of the api's `throwAuthErrorResponse`. `AuthError.status` is the HTTP
146
+ * status GoTrue answered with; network/unknown failures carry none, hence the 500 fallback.
147
+ */
148
+ const mapAuthError = (error) => new SupabaseClientError({
149
+ status: error.status ?? 500,
150
+ error: 'Authentication Error',
151
+ message: error.message,
152
+ }, { cause: error });
153
+ exports.mapAuthError = mapAuthError;
143
154
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAcA;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAS;IACf,KAAK,CAAS;IACd,IAAI,CAAU;IAEvB,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAA2B,EAAE,OAA6B;QAClG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,UAAU;QACR,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC;CACF;AAhBD,kDAgBC;AAED,MAAM,6BAA6B,GAA2B;IAC5D,uBAAuB;IACvB,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IAEb,wBAAwB;IACxB,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EA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AAE,KAAK,CAAC,MAAM,IAAI,GAAG;IAC3B,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;CACvB,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;AARS,QAAA,YAAY,gBAQrB"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './client';
2
2
  export * from './auth';
3
+ export * from './auth-client';
3
4
  export * from './errors';
4
5
  export * from './validators';
5
6
  export * from './transforms';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client"), exports);
18
18
  __exportStar(require("./auth"), exports);
19
+ __exportStar(require("./auth-client"), exports);
19
20
  __exportStar(require("./errors"), exports);
20
21
  __exportStar(require("./validators"), exports);
21
22
  __exportStar(require("./transforms"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,uDAAqC;AACrC,0CAAwB;AACxB,qDAAmC;AACnC,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,gDAA8B;AAC9B,2CAAyB;AACzB,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,uDAAqC;AACrC,0CAAwB;AACxB,qDAAmC;AACnC,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB"}
@@ -7,3 +7,8 @@ import { SupabaseClientError } from '../errors';
7
7
  */
8
8
  export declare const toHttpException: (error: SupabaseClientError) => HttpException;
9
9
  export declare const SupabaseUserClient: (...dataOrPipes: unknown[]) => ParameterDecorator;
10
+ /**
11
+ * A `SupabaseAuthClient` for routes a logged-out caller hits (sign-in, refresh, password
12
+ * reset) — built from the publishable key alone, with no bearer token involved.
13
+ */
14
+ export declare const SupabasePublicClient: (...dataOrPipes: any[]) => ParameterDecorator;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SupabaseUserClient = exports.toHttpException = void 0;
3
+ exports.SupabasePublicClient = exports.SupabaseUserClient = exports.toHttpException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
+ const auth_client_1 = require("../auth-client");
5
6
  const client_1 = require("../client");
6
7
  const errors_1 = require("../errors");
7
8
  /**
@@ -44,4 +45,12 @@ exports.SupabaseUserClient = (0, common_1.createParamDecorator)((_, ctx) => {
44
45
  throw error;
45
46
  }
46
47
  });
48
+ /**
49
+ * A `SupabaseAuthClient` for routes a logged-out caller hits (sign-in, refresh, password
50
+ * reset) — built from the publishable key alone, with no bearer token involved.
51
+ */
52
+ exports.SupabasePublicClient = (0, common_1.createParamDecorator)(() => (0, auth_client_1.createSupabaseAuthClient)({
53
+ url: getEnvOrThrow('SUPABASE_URL'),
54
+ key: getEnvOrThrow('SUPABASE_PUBLISHABLE_KEY'),
55
+ }));
47
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nest/index.ts"],"names":[],"mappings":";;;AAAA,2CAMwB;AAExB,sCAAsE;AACtE,sCAAgD;AAEhD;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,KAA0B,EAAiB,EAAE,CAC3E,IAAI,sBAAa,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAD3D,QAAA,eAAe,mBAC4C;AAExE,MAAM,aAAa,GAAG,CAAC,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,CAAC,CAAC;IACvE,IAAI,CAAC;QACH,OAAO,IAAA,6BAAoB,EAAC;YAC1B,GAAG,EAAE,aAAa,CAAC,cAAc,CAAC;YAClC,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC;YAC9C,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+EAA+E;QAC/E,qCAAqC;QACrC,IAAI,KAAK,YAAY,4BAAmB;YAAE,MAAM,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC;AAEF;;;GAGG;AACU,QAAA,oBAAoB,GAAG,IAAA,6BAAoB,EACtD,GAAuB,EAAE,CACvB,IAAA,sCAAwB,EAAC;IACvB,GAAG,EAAE,aAAa,CAAC,cAAc,CAAC;IAClC,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC;CAC/C,CAAC,CACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managemint-solutions/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Typed Supabase data-access SDK for ManageMint Solutions",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Scott Bebington <scottbebington@gmail.com>",