@thetinkerinc/sprout 0.1.1 → 0.1.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.
@@ -0,0 +1,7 @@
1
+ declare function getEmail(userId: string): Promise<string>;
2
+ declare function getUserId(email: string): Promise<string>;
3
+ declare const _default: {
4
+ getEmail: typeof getEmail;
5
+ getUserId: typeof getUserId;
6
+ };
7
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { createClerkClient } from 'svelte-clerk/server';
2
+ import { PUBLIC_CLERK_PUBLISHABLE_KEY } from '$env/static/public';
3
+ import { CLERK_SECRET_KEY } from '$env/static/private';
4
+ async function getEmail(userId) {
5
+ const clerk = getClerk();
6
+ const user = await clerk.users.getUser(userId);
7
+ return user.emailAddresses[0].emailAddress;
8
+ }
9
+ async function getUserId(email) {
10
+ const clerk = getClerk();
11
+ const users = await clerk.users.getUserList({
12
+ limit: 1,
13
+ emailAddress: [email]
14
+ });
15
+ if (users.totalCount === 0) {
16
+ throw new Error(`No user found with email ${email}`);
17
+ }
18
+ return users.data[0].id;
19
+ }
20
+ function getClerk() {
21
+ return createClerkClient({
22
+ publishableKey: PUBLIC_CLERK_PUBLISHABLE_KEY,
23
+ secretKey: CLERK_SECRET_KEY
24
+ });
25
+ }
26
+ export default {
27
+ getEmail,
28
+ getUserId
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thetinkerinc/sprout",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -37,6 +37,10 @@
37
37
  "./commanders": {
38
38
  "types": "./dist/commanders/index.d.ts",
39
39
  "svelte": "./dist/commanders/index.js"
40
+ },
41
+ "./auth": {
42
+ "types": "./dist/auth/index.d.ts",
43
+ "svelte": "./dist/auth/index.js"
40
44
  }
41
45
  },
42
46
  "peerDependencies": {