@koloseum/utils 0.1.16 → 0.1.17
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/utils.d.ts +12 -1
- package/dist/utils.js +58 -0
- package/package.json +2 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { Database } from "@koloseum/types/database";
|
|
2
|
-
import type { CustomError, Microservice, MicroserviceGroup, MicroserviceObject } from "@koloseum/types/general";
|
|
2
|
+
import type { CustomError, Microservice, MicroserviceGroup, MicroserviceObject, UserWithAppMetadata } from "@koloseum/types/general";
|
|
3
3
|
import type { PronounsCheckboxes, SocialMediaPlatform } from "@koloseum/types/public-auth";
|
|
4
4
|
import type { Page } from "@sveltejs/kit";
|
|
5
5
|
import type { SupabaseClient, PostgrestError } from "@supabase/supabase-js";
|
|
6
6
|
import type { suprsend } from "@suprsend/node-sdk";
|
|
7
7
|
import type { IOptions } from "@suprsend/web-components/dist/types/interface.d.ts";
|
|
8
8
|
import type { MobilePhoneLocale } from "validator";
|
|
9
|
+
export declare const Data: {
|
|
10
|
+
/**
|
|
11
|
+
* A generic authenticated user.
|
|
12
|
+
* @param {string} id - The user ID; defaults to a random UUID
|
|
13
|
+
* @param {Date} date - The date and time; defaults to the current date and time
|
|
14
|
+
* @param {string} phone - The phone number; defaults to a generic Kenyan phone number
|
|
15
|
+
* @param {string} identityId - A default identity ID; defaults to a random UUID
|
|
16
|
+
* @returns A generic authenticated user.
|
|
17
|
+
*/
|
|
18
|
+
authenticatedUser: (id?: string, date?: Date, phone?: string, identityId?: string) => UserWithAppMetadata;
|
|
19
|
+
};
|
|
9
20
|
export declare const Status: {
|
|
10
21
|
/**
|
|
11
22
|
* A generic error message.
|
package/dist/utils.js
CHANGED
|
@@ -1,9 +1,67 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
1
2
|
import { error as svelteError } from "@sveltejs/kit";
|
|
2
3
|
import { FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/supabase-js";
|
|
3
4
|
import sanitize from "sanitize-html";
|
|
4
5
|
import validator from "validator";
|
|
5
6
|
/* Helper functions */
|
|
6
7
|
const { isMobilePhone, isURL } = validator;
|
|
8
|
+
/* Dummy data */
|
|
9
|
+
export const Data = {
|
|
10
|
+
/**
|
|
11
|
+
* A generic authenticated user.
|
|
12
|
+
* @param {string} id - The user ID; defaults to a random UUID
|
|
13
|
+
* @param {Date} date - The date and time; defaults to the current date and time
|
|
14
|
+
* @param {string} phone - The phone number; defaults to a generic Kenyan phone number
|
|
15
|
+
* @param {string} identityId - A default identity ID; defaults to a random UUID
|
|
16
|
+
* @returns A generic authenticated user.
|
|
17
|
+
*/
|
|
18
|
+
authenticatedUser: (id = uuidv4(), date = new Date(), phone = "254111222333", identityId = uuidv4()) => {
|
|
19
|
+
// Convert date to ISO string
|
|
20
|
+
const time = date.toISOString();
|
|
21
|
+
// User data
|
|
22
|
+
return {
|
|
23
|
+
id,
|
|
24
|
+
aud: "authenticated",
|
|
25
|
+
role: "authenticated",
|
|
26
|
+
email: "",
|
|
27
|
+
phone,
|
|
28
|
+
phone_confirmed_at: time,
|
|
29
|
+
confirmation_sent_at: time,
|
|
30
|
+
confirmed_at: time,
|
|
31
|
+
last_sign_in_at: time,
|
|
32
|
+
app_metadata: {
|
|
33
|
+
person_data: { first_name: "John", last_name: "Test", pseudonym: "JDtest" },
|
|
34
|
+
provider: "phone",
|
|
35
|
+
providers: ["phone"],
|
|
36
|
+
roles: ["player", "backroom_superuser"]
|
|
37
|
+
},
|
|
38
|
+
user_metadata: {
|
|
39
|
+
email_verified: false,
|
|
40
|
+
phone_verified: false,
|
|
41
|
+
sub: id
|
|
42
|
+
},
|
|
43
|
+
identities: [
|
|
44
|
+
{
|
|
45
|
+
identity_id: identityId,
|
|
46
|
+
id,
|
|
47
|
+
user_id: id,
|
|
48
|
+
identity_data: {
|
|
49
|
+
email_verified: false,
|
|
50
|
+
phone_verified: false,
|
|
51
|
+
sub: id
|
|
52
|
+
},
|
|
53
|
+
provider: "phone",
|
|
54
|
+
last_sign_in_at: time,
|
|
55
|
+
created_at: time,
|
|
56
|
+
updated_at: time
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
created_at: time,
|
|
60
|
+
updated_at: time,
|
|
61
|
+
is_anonymous: false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
7
65
|
/* Status messages */
|
|
8
66
|
export const Status = {
|
|
9
67
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@suprsend/node-sdk": "^1.13.0",
|
|
41
41
|
"@suprsend/web-components": "^0.2.1",
|
|
42
42
|
"@types/sanitize-html": "^2.13.0",
|
|
43
|
+
"@types/uuid": "^10.0.0",
|
|
43
44
|
"@types/validator": "^13.12.2",
|
|
44
45
|
"prettier": "^3.5.1",
|
|
45
46
|
"typescript": "^5.0.0",
|