@inflector/aura 0.5.0 → 0.5.2

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/dist/auth.d.ts CHANGED
@@ -1482,5 +1482,7 @@ export declare const AuraAuth: (url: string, workspace: string) => {
1482
1482
  statusText: string;
1483
1483
  };
1484
1484
  }>;
1485
+ GetScopes: () => Promise<any>;
1486
+ HasScopes: (scope: string) => Promise<any>;
1485
1487
  };
1486
1488
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmG3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;yBAQxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;0BACN,MAAM,EAAE;;;;;;;;;;;;;;;yBACT,MAAM,EAAE;;;;;;;;;;;;;;;yBACR,MAAM,EAAE;;;;;;;;;;;;;;;oBACb,MAAM,EAAE;;;;;;;;;;;;;;;qBACP,MAAM,EAAE;;;;;;;;;;;;;;;uBACN,MAAM,EAAE;;;;;;;;;;;;;;;;+BAIA,MAAM;;;;;;;;;;;;;;;;;;uBAgBT,MAAM;CAcjC,CAAC"}
package/dist/auth.js CHANGED
@@ -1,3 +1,4 @@
1
+ import axios from "axios";
1
2
  import { createAuthClient } from "better-auth/client";
2
3
  import { anonymousClient } from "better-auth/client/plugins";
3
4
  import { atom } from "nanostores";
@@ -12,7 +13,7 @@ export const AuraAuth = (url, workspace) => {
12
13
  baseURL: `${url}/api/auth/${workspace}`,
13
14
  plugins: [anonymousClient()],
14
15
  fetchOptions: {
15
- credentials: "include"
16
+ credentials: "include",
16
17
  },
17
18
  });
18
19
  const Session = atom({
@@ -102,6 +103,11 @@ export const AuraAuth = (url, workspace) => {
102
103
  };
103
104
  // Initialize auth on creation
104
105
  initialize();
106
+ const post = (body, name) => {
107
+ return axios
108
+ .post(`/api/db/${workspace}/${name}`, body, { withCredentials: true })
109
+ .then((r) => r.data);
110
+ };
105
111
  return {
106
112
  Logout: authClient.signOut,
107
113
  Email: {
@@ -173,5 +179,25 @@ export const AuraAuth = (url, workspace) => {
173
179
  };
174
180
  })(),
175
181
  GetAccessToken: (provider) => authClient.getAccessToken({ providerId: provider }),
182
+ GetScopes: async () => {
183
+ return (await post({
184
+ operation: "GetOne",
185
+ settings: {
186
+ where: {
187
+ userId: User.id,
188
+ },
189
+ },
190
+ }, "account")).scope.split(",");
191
+ },
192
+ HasScopes: async (scope) => {
193
+ return (await post({
194
+ operation: "GetOne",
195
+ settings: {
196
+ where: {
197
+ userId: User.id,
198
+ },
199
+ },
200
+ }, "account")).scope.split(",").includes(scope);
201
+ },
176
202
  };
177
203
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflector/aura",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",