@thetinkerinc/sprout 0.1.0 → 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.
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.js +29 -0
- package/dist/commanders/index.d.ts +12 -0
- package/dist/index.js +0 -1
- package/package.json +6 -4
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { makeCommander } from '@thetinkerinc/commander';
|
|
2
|
+
import { getDb } from '../db';
|
|
3
|
+
type Commander<T> = ReturnType<typeof makeCommander<Promise<T>>>;
|
|
4
|
+
type Db = Awaited<ReturnType<typeof getDb>>;
|
|
5
|
+
export declare const Anonymous: Commander<{
|
|
6
|
+
db: Db;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const Authenticated: Commander<{
|
|
9
|
+
userId: string;
|
|
10
|
+
db: Db;
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thetinkerinc/sprout",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -22,9 +22,6 @@
|
|
|
22
22
|
"!dist/**/*.test.*",
|
|
23
23
|
"!dist/**/*.spec.*"
|
|
24
24
|
],
|
|
25
|
-
"sideEffects": [
|
|
26
|
-
"**/*.css"
|
|
27
|
-
],
|
|
28
25
|
"svelte": "./dist/index.js",
|
|
29
26
|
"types": "./dist/index.d.ts",
|
|
30
27
|
"type": "module",
|
|
@@ -38,7 +35,12 @@
|
|
|
38
35
|
"svelte": "./dist/db/index.js"
|
|
39
36
|
},
|
|
40
37
|
"./commanders": {
|
|
38
|
+
"types": "./dist/commanders/index.d.ts",
|
|
41
39
|
"svelte": "./dist/commanders/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./auth": {
|
|
42
|
+
"types": "./dist/auth/index.d.ts",
|
|
43
|
+
"svelte": "./dist/auth/index.js"
|
|
42
44
|
}
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|