@passlock/node 2.0.0-beta.1 → 2.0.0-beta.3
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/effects/index.d.ts +5 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/index.js +5 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/passkey/effects.d.ts +18 -0
- package/dist/passkey/effects.d.ts.map +1 -0
- package/dist/passkey/effects.js +61 -0
- package/dist/passkey/effects.js.map +1 -0
- package/dist/passkey/index.d.ts +50 -0
- package/dist/passkey/index.d.ts.map +1 -0
- package/dist/passkey/index.js +45 -0
- package/dist/passkey/index.js.map +1 -0
- package/dist/principal/effects.d.ts +18 -0
- package/dist/principal/effects.d.ts.map +1 -0
- package/dist/principal/effects.js +64 -0
- package/dist/principal/effects.js.map +1 -0
- package/dist/principal/index.d.ts +10 -9
- package/dist/principal/index.d.ts.map +1 -1
- package/dist/principal/index.js +7 -26
- package/dist/principal/index.js.map +1 -1
- package/dist/schemas/errors.d.ts +68 -0
- package/dist/schemas/errors.d.ts.map +1 -0
- package/dist/schemas/errors.js +34 -0
- package/dist/schemas/errors.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/passkey.d.ts +127 -0
- package/dist/schemas/passkey.d.ts.map +1 -0
- package/dist/schemas/passkey.js +96 -0
- package/dist/schemas/passkey.js.map +1 -0
- package/dist/schemas/principal.d.ts +48 -0
- package/dist/schemas/principal.d.ts.map +1 -0
- package/dist/schemas/principal.js +50 -0
- package/dist/schemas/principal.js.map +1 -0
- package/dist/schemas/signup.d.ts +13 -0
- package/dist/schemas/signup.d.ts.map +1 -0
- package/dist/schemas/signup.js +11 -0
- package/dist/schemas/signup.js.map +1 -0
- package/dist/shared.d.ts +0 -20
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -12
- package/dist/shared.js.map +1 -1
- package/dist/testUtils.d.ts +11 -0
- package/dist/testUtils.d.ts.map +1 -0
- package/dist/testUtils.js +25 -0
- package/dist/testUtils.js.map +1 -0
- package/package.json +27 -28
- package/dist/principal/effect.d.ts +0 -53
- package/dist/principal/effect.d.ts.map +0 -1
- package/dist/principal/effect.js +0 -78
- package/dist/principal/effect.js.map +0 -1
- package/dist/user/effect.d.ts +0 -18
- package/dist/user/effect.d.ts.map +0 -1
- package/dist/user/effect.js +0 -27
- package/dist/user/effect.js.map +0 -1
- package/dist/user/index.d.ts +0 -18
- package/dist/user/index.d.ts.map +0 -1
- package/dist/user/index.js +0 -36
- package/dist/user/index.js.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export class Unauthorized extends Schema.TaggedError()("@error/Unauthorized", {}) {
|
|
3
|
+
}
|
|
4
|
+
export class Forbidden extends Schema.TaggedError()("@error/Forbidden", {}) {
|
|
5
|
+
}
|
|
6
|
+
export class InvalidCode extends Schema.TaggedError("@error/InvalidCode")("@error/InvalidCode", {
|
|
7
|
+
message: Schema.String,
|
|
8
|
+
}) {
|
|
9
|
+
}
|
|
10
|
+
export class InvalidTenancy extends Schema.TaggedError()("@error/InvalidTenancy", {
|
|
11
|
+
message: Schema.String,
|
|
12
|
+
}) {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* We need the credentialId and rpId to feed into the
|
|
16
|
+
* client's signalCredentialRemoval function
|
|
17
|
+
*/
|
|
18
|
+
export class PasskeyNotFound extends Schema.TaggedError("@error/PasskeyNotFound")("@error/PasskeyNotFound", {
|
|
19
|
+
credentialId: Schema.String,
|
|
20
|
+
message: Schema.String,
|
|
21
|
+
rpId: Schema.String,
|
|
22
|
+
}) {
|
|
23
|
+
}
|
|
24
|
+
export class NotFound extends Schema.TaggedError("@error/NotFound")("@error/NotFound", {
|
|
25
|
+
message: Schema.String,
|
|
26
|
+
}) {
|
|
27
|
+
}
|
|
28
|
+
export class InvalidEmail extends Schema.TaggedError("@error/InvalidEmail")("@error/InvalidEmail", { message: Schema.String }) {
|
|
29
|
+
}
|
|
30
|
+
export class DuplicateEmail extends Schema.TaggedError("@error/DuplicateEmail")("@error/DuplicateEmail", { message: Schema.String }) {
|
|
31
|
+
}
|
|
32
|
+
export class BadRequest extends Schema.TaggedError("@error/BadRequest")("@error/BadRequest", { message: Schema.String }) {
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,qBAAqB,EAAE,EAAE,CAAC;CAAG;AAElG,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,EAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAAG;AAEzF,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,CAAc,oBAAoB,CAAC,CACpF,oBAAoB,EACpB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,EAAkB,CAAC,uBAAuB,EAAE;IAChG,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,CAAkB,wBAAwB,CAAC,CAChG,wBAAwB,EACxB;IACE,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CACF;CAAG;AAEJ,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,WAAW,CAAW,iBAAiB,CAAC,CAAC,iBAAiB,EAAE;IAC/F,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,qBAAqB,CAAC,CACvF,qBAAqB,EACrB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG;AAEJ,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,CAAiB,uBAAuB,CAAC,CAC7F,uBAAuB,EACvB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG;AAEJ,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAa,mBAAmB,CAAC,CACjF,mBAAmB,EACnB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG","sourcesContent":["import { Schema } from \"effect\"\n\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\"@error/Unauthorized\", {}) {}\n\nexport class Forbidden extends Schema.TaggedError<Forbidden>()(\"@error/Forbidden\", {}) {}\n\nexport class InvalidCode extends Schema.TaggedError<InvalidCode>(\"@error/InvalidCode\")(\n \"@error/InvalidCode\",\n {\n message: Schema.String,\n }\n) {}\n\nexport class InvalidTenancy extends Schema.TaggedError<InvalidTenancy>()(\"@error/InvalidTenancy\", {\n message: Schema.String,\n}) {}\n\n/**\n * We need the credentialId and rpId to feed into the\n * client's signalCredentialRemoval function\n */\nexport class PasskeyNotFound extends Schema.TaggedError<PasskeyNotFound>(\"@error/PasskeyNotFound\")(\n \"@error/PasskeyNotFound\",\n {\n credentialId: Schema.String,\n message: Schema.String,\n rpId: Schema.String,\n }\n) {}\n\nexport class NotFound extends Schema.TaggedError<NotFound>(\"@error/NotFound\")(\"@error/NotFound\", {\n message: Schema.String,\n}) {}\n\nexport class InvalidEmail extends Schema.TaggedError<InvalidEmail>(\"@error/InvalidEmail\")(\n \"@error/InvalidEmail\",\n { message: Schema.String }\n) {}\n\nexport class DuplicateEmail extends Schema.TaggedError<DuplicateEmail>(\"@error/DuplicateEmail\")(\n \"@error/DuplicateEmail\",\n { message: Schema.String }\n) {}\n\nexport class BadRequest extends Schema.TaggedError<BadRequest>(\"@error/BadRequest\")(\n \"@error/BadRequest\",\n { message: Schema.String }\n) {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA","sourcesContent":["export * from \"./errors.js\"\nexport * from \"./passkey.js\"\nexport * from \"./principal.js\"\nexport * from \"./signup.js\"\n"]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const UserVerificationSchema: Schema.Literal<["required", "preferred", "discouraged"]>;
|
|
3
|
+
export declare const RegistrationOptionsRequest: Schema.Struct<{
|
|
4
|
+
excludeCredentials: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
|
|
5
|
+
default: () => never[];
|
|
6
|
+
}>;
|
|
7
|
+
timeout: Schema.optional<typeof Schema.Number>;
|
|
8
|
+
userDisplayName: Schema.optional<typeof Schema.String>;
|
|
9
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
10
|
+
username: typeof Schema.String;
|
|
11
|
+
userVerification: Schema.optional<Schema.Literal<["required", "preferred", "discouraged"]>>;
|
|
12
|
+
}>;
|
|
13
|
+
export type RegistrationOptionsRequest = typeof RegistrationOptionsRequest.Type;
|
|
14
|
+
export declare const RegistrationOptionsResponse: Schema.Struct<{
|
|
15
|
+
optionsJSON: typeof Schema.Object;
|
|
16
|
+
sessionToken: typeof Schema.String;
|
|
17
|
+
}>;
|
|
18
|
+
export type RegistrationOptionsResponse = typeof RegistrationOptionsResponse.Type;
|
|
19
|
+
export declare const RegistrationVerificationRequest: Schema.Struct<{
|
|
20
|
+
response: typeof Schema.Object;
|
|
21
|
+
sessionToken: typeof Schema.String;
|
|
22
|
+
}>;
|
|
23
|
+
export type RegistrationVerificationRequest = typeof RegistrationVerificationRequest.Type;
|
|
24
|
+
export declare const RegistrationVerificationResponse: Schema.TaggedStruct<"RegistrationSuccess", {
|
|
25
|
+
code: typeof Schema.String;
|
|
26
|
+
id_token: typeof Schema.String;
|
|
27
|
+
principal: Schema.TaggedStruct<"Principal", {
|
|
28
|
+
id: typeof Schema.String;
|
|
29
|
+
authenticatorId: typeof Schema.String;
|
|
30
|
+
authenticatorType: Schema.Literal<["passkey"]>;
|
|
31
|
+
createdAt: typeof Schema.Number;
|
|
32
|
+
expiresAt: typeof Schema.Number;
|
|
33
|
+
passkey: Schema.optional<Schema.Struct<{
|
|
34
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
35
|
+
userVerified: typeof Schema.Boolean;
|
|
36
|
+
verified: typeof Schema.Boolean;
|
|
37
|
+
}>>;
|
|
38
|
+
userId: typeof Schema.String;
|
|
39
|
+
}>;
|
|
40
|
+
}>;
|
|
41
|
+
export type RegistrationVerificationResponse = typeof RegistrationVerificationResponse.Type;
|
|
42
|
+
export declare const AuthenticationOptionsRequest: Schema.Struct<{
|
|
43
|
+
allowCredentials: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
|
|
44
|
+
default: () => never[];
|
|
45
|
+
}>;
|
|
46
|
+
timeout: Schema.optional<typeof Schema.Number>;
|
|
47
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
48
|
+
userVerification: Schema.optional<Schema.Literal<["required", "preferred", "discouraged"]>>;
|
|
49
|
+
}>;
|
|
50
|
+
export type AuthenticationOptionsRequest = typeof AuthenticationOptionsRequest.Type;
|
|
51
|
+
export declare const AuthenticationVerificationRequest: Schema.Struct<{
|
|
52
|
+
response: typeof Schema.Object;
|
|
53
|
+
sessionToken: typeof Schema.String;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const AuthenticationVerificationResponse: Schema.TaggedStruct<"AuthenticationSuccess", {
|
|
56
|
+
code: typeof Schema.String;
|
|
57
|
+
id_token: typeof Schema.String;
|
|
58
|
+
principal: Schema.TaggedStruct<"Principal", {
|
|
59
|
+
id: typeof Schema.String;
|
|
60
|
+
authenticatorId: typeof Schema.String;
|
|
61
|
+
authenticatorType: Schema.Literal<["passkey"]>;
|
|
62
|
+
createdAt: typeof Schema.Number;
|
|
63
|
+
expiresAt: typeof Schema.Number;
|
|
64
|
+
passkey: Schema.optional<Schema.Struct<{
|
|
65
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
66
|
+
userVerified: typeof Schema.Boolean;
|
|
67
|
+
verified: typeof Schema.Boolean;
|
|
68
|
+
}>>;
|
|
69
|
+
userId: typeof Schema.String;
|
|
70
|
+
}>;
|
|
71
|
+
}>;
|
|
72
|
+
export type AuthenticationVerificationResponse = typeof AuthenticationVerificationResponse.Type;
|
|
73
|
+
export declare const CredentialDeviceType: readonly ["singleDevice", "multiDevice"];
|
|
74
|
+
export type CredentialDeviceType = (typeof CredentialDeviceType)[number];
|
|
75
|
+
export declare const Transports: readonly ["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"];
|
|
76
|
+
export type Transports = (typeof Transports)[number];
|
|
77
|
+
export declare const Passkey: Schema.TaggedStruct<"Passkey", {
|
|
78
|
+
createdAt: typeof Schema.Number;
|
|
79
|
+
credential: Schema.Struct<{
|
|
80
|
+
aaguid: typeof Schema.String;
|
|
81
|
+
backedUp: typeof Schema.Boolean;
|
|
82
|
+
counter: typeof Schema.Number;
|
|
83
|
+
deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
|
|
84
|
+
id: typeof Schema.String;
|
|
85
|
+
transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
|
|
86
|
+
userId: typeof Schema.String;
|
|
87
|
+
}>;
|
|
88
|
+
enabled: typeof Schema.Boolean;
|
|
89
|
+
id: typeof Schema.String;
|
|
90
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
91
|
+
platform: Schema.optional<Schema.Struct<{
|
|
92
|
+
icon: Schema.optional<typeof Schema.String>;
|
|
93
|
+
name: Schema.optional<typeof Schema.String>;
|
|
94
|
+
}>>;
|
|
95
|
+
updatedAt: typeof Schema.Number;
|
|
96
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
97
|
+
}>;
|
|
98
|
+
export type Passkey = typeof Passkey.Type;
|
|
99
|
+
export declare const isPasskey: (payload: unknown) => payload is Passkey;
|
|
100
|
+
export declare const PasskeySummary: Schema.TaggedStruct<"PasskeySummary", {
|
|
101
|
+
createdAt: typeof Schema.Number;
|
|
102
|
+
credential: Schema.Struct<{
|
|
103
|
+
aaguid: typeof Schema.String;
|
|
104
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
105
|
+
}>;
|
|
106
|
+
enabled: typeof Schema.Boolean;
|
|
107
|
+
id: typeof Schema.String;
|
|
108
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
109
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
110
|
+
}>;
|
|
111
|
+
export type PasskeySummary = typeof PasskeySummary.Type;
|
|
112
|
+
export declare const isPasskeySummary: (payload: unknown) => payload is PasskeySummary;
|
|
113
|
+
export declare const FindAllPasskeys: Schema.TaggedStruct<"FindAllPasskeys", {
|
|
114
|
+
cursor: Schema.NullOr<typeof Schema.String>;
|
|
115
|
+
records: Schema.Array$<Schema.TaggedStruct<"PasskeySummary", {
|
|
116
|
+
createdAt: typeof Schema.Number;
|
|
117
|
+
credential: Schema.Struct<{
|
|
118
|
+
aaguid: typeof Schema.String;
|
|
119
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
120
|
+
}>;
|
|
121
|
+
enabled: typeof Schema.Boolean;
|
|
122
|
+
id: typeof Schema.String;
|
|
123
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
124
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
125
|
+
}>>;
|
|
126
|
+
}>;
|
|
127
|
+
//# sourceMappingURL=passkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/schemas/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,eAAO,MAAM,sBAAsB,0DAAyD,CAAA;AAE5F,eAAO,MAAM,0BAA0B;;;;;;;;;EAOrC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAC,IAAI,CAAA;AAE/E,eAAO,MAAM,2BAA2B;;;EAGtC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,2BAA2B,CAAC,IAAI,CAAA;AAIjF,eAAO,MAAM,+BAA+B;;;EAG1C,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,OAAO,+BAA+B,CAAC,IAAI,CAAA;AAGzF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;EAI3C,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,OAAO,gCAAgC,CAAC,IAAI,CAAA;AAI3F,eAAO,MAAM,4BAA4B;;;;;;;EAKvC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,OAAO,4BAA4B,CAAC,IAAI,CAAA;AAInF,eAAO,MAAM,iCAAiC;;;EAG5C,CAAA;AAGF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;EAI7C,CAAA;AAEF,MAAM,MAAM,kCAAkC,GAAG,OAAO,kCAAkC,CAAC,IAAI,CAAA;AAI/F,eAAO,MAAM,oBAAoB,0CAA2C,CAAA;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExE,eAAO,MAAM,UAAU,6EAQb,CAAA;AACV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAIpD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;EAsBlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,OAAsC,CAAA;AAE9F,eAAO,MAAM,cAAc;;;;;;;;;;EAUzB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,cAC3B,CAAA;AAEpC,eAAO,MAAM,eAAe;;;;;;;;;;;;;EAG1B,CAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Principal } from "./principal.js";
|
|
3
|
+
/* Registration Options */
|
|
4
|
+
export const UserVerificationSchema = Schema.Literal("required", "preferred", "discouraged");
|
|
5
|
+
export const RegistrationOptionsRequest = Schema.Struct({
|
|
6
|
+
excludeCredentials: Schema.optionalWith(Schema.Array(Schema.String), { default: () => [] }),
|
|
7
|
+
timeout: Schema.optional(Schema.Number),
|
|
8
|
+
userDisplayName: Schema.optional(Schema.String),
|
|
9
|
+
userId: Schema.optional(Schema.String),
|
|
10
|
+
username: Schema.String,
|
|
11
|
+
userVerification: Schema.optional(UserVerificationSchema),
|
|
12
|
+
});
|
|
13
|
+
export const RegistrationOptionsResponse = Schema.Struct({
|
|
14
|
+
optionsJSON: Schema.Object,
|
|
15
|
+
sessionToken: Schema.String,
|
|
16
|
+
});
|
|
17
|
+
/* Registration Verification */
|
|
18
|
+
export const RegistrationVerificationRequest = Schema.Struct({
|
|
19
|
+
response: Schema.Object,
|
|
20
|
+
sessionToken: Schema.String,
|
|
21
|
+
});
|
|
22
|
+
// maps to RegistrationSuccess on the client side
|
|
23
|
+
export const RegistrationVerificationResponse = Schema.TaggedStruct("RegistrationSuccess", {
|
|
24
|
+
code: Schema.String,
|
|
25
|
+
id_token: Schema.String,
|
|
26
|
+
principal: Principal,
|
|
27
|
+
});
|
|
28
|
+
/* Authentication Options */
|
|
29
|
+
export const AuthenticationOptionsRequest = Schema.Struct({
|
|
30
|
+
allowCredentials: Schema.optionalWith(Schema.Array(Schema.String), { default: () => [] }),
|
|
31
|
+
timeout: Schema.optional(Schema.Number),
|
|
32
|
+
userId: Schema.optional(Schema.String),
|
|
33
|
+
userVerification: Schema.optional(UserVerificationSchema),
|
|
34
|
+
});
|
|
35
|
+
/* Authentication Verification */
|
|
36
|
+
export const AuthenticationVerificationRequest = Schema.Struct({
|
|
37
|
+
response: Schema.Object,
|
|
38
|
+
sessionToken: Schema.String,
|
|
39
|
+
});
|
|
40
|
+
// maps to AuthenticationSuccess on the client
|
|
41
|
+
export const AuthenticationVerificationResponse = Schema.TaggedStruct("AuthenticationSuccess", {
|
|
42
|
+
code: Schema.String,
|
|
43
|
+
id_token: Schema.String,
|
|
44
|
+
principal: Principal,
|
|
45
|
+
});
|
|
46
|
+
/* Passkey */
|
|
47
|
+
export const CredentialDeviceType = ["singleDevice", "multiDevice"];
|
|
48
|
+
export const Transports = [
|
|
49
|
+
"ble",
|
|
50
|
+
"hybrid",
|
|
51
|
+
"internal",
|
|
52
|
+
"nfc",
|
|
53
|
+
"usb",
|
|
54
|
+
"cable",
|
|
55
|
+
"smart-card",
|
|
56
|
+
];
|
|
57
|
+
/* Passkey */
|
|
58
|
+
export const Passkey = Schema.TaggedStruct("Passkey", {
|
|
59
|
+
createdAt: Schema.Number,
|
|
60
|
+
credential: Schema.Struct({
|
|
61
|
+
aaguid: Schema.String,
|
|
62
|
+
backedUp: Schema.Boolean,
|
|
63
|
+
counter: Schema.Number,
|
|
64
|
+
deviceType: Schema.Literal(...CredentialDeviceType),
|
|
65
|
+
id: Schema.String, // webAuthnId (Base64Url)
|
|
66
|
+
transports: Schema.Array(Schema.Literal(...Transports)),
|
|
67
|
+
userId: Schema.String, // webAuthnUserId (Base64Url)
|
|
68
|
+
}),
|
|
69
|
+
enabled: Schema.Boolean,
|
|
70
|
+
id: Schema.String,
|
|
71
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
72
|
+
platform: Schema.optional(Schema.Struct({
|
|
73
|
+
icon: Schema.optional(Schema.String),
|
|
74
|
+
name: Schema.optional(Schema.String),
|
|
75
|
+
})),
|
|
76
|
+
updatedAt: Schema.Number,
|
|
77
|
+
userId: Schema.optional(Schema.String),
|
|
78
|
+
});
|
|
79
|
+
export const isPasskey = (payload) => Schema.is(Passkey)(payload);
|
|
80
|
+
export const PasskeySummary = Schema.TaggedStruct("PasskeySummary", {
|
|
81
|
+
createdAt: Schema.Number,
|
|
82
|
+
credential: Schema.Struct({
|
|
83
|
+
aaguid: Schema.String,
|
|
84
|
+
platformName: Schema.optional(Schema.String),
|
|
85
|
+
}),
|
|
86
|
+
enabled: Schema.Boolean,
|
|
87
|
+
id: Schema.String,
|
|
88
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
89
|
+
userId: Schema.optional(Schema.String),
|
|
90
|
+
});
|
|
91
|
+
export const isPasskeySummary = (payload) => Schema.is(PasskeySummary)(payload);
|
|
92
|
+
export const FindAllPasskeys = Schema.TaggedStruct("FindAllPasskeys", {
|
|
93
|
+
cursor: Schema.NullOr(Schema.String),
|
|
94
|
+
records: Schema.Array(PasskeySummary),
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=passkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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;QACxB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;KAC7C,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACvC,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAA6B,EAAE,CAC9E,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACpE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;CACtC,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\nimport { Principal } from \"./principal.js\"\n\n/* Registration Options */\n\nexport const UserVerificationSchema = Schema.Literal(\"required\", \"preferred\", \"discouraged\")\n\nexport const RegistrationOptionsRequest = Schema.Struct({\n excludeCredentials: Schema.optionalWith(Schema.Array(Schema.String), { default: () => [] }),\n timeout: Schema.optional(Schema.Number),\n userDisplayName: Schema.optional(Schema.String),\n userId: Schema.optional(Schema.String),\n username: Schema.String,\n userVerification: Schema.optional(UserVerificationSchema),\n})\n\nexport type RegistrationOptionsRequest = typeof RegistrationOptionsRequest.Type\n\nexport const RegistrationOptionsResponse = Schema.Struct({\n optionsJSON: Schema.Object,\n sessionToken: Schema.String,\n})\n\nexport type RegistrationOptionsResponse = typeof RegistrationOptionsResponse.Type\n\n/* Registration Verification */\n\nexport const RegistrationVerificationRequest = Schema.Struct({\n response: Schema.Object,\n sessionToken: Schema.String,\n})\n\nexport type RegistrationVerificationRequest = typeof RegistrationVerificationRequest.Type\n\n// maps to RegistrationSuccess on the client side\nexport const RegistrationVerificationResponse = Schema.TaggedStruct(\"RegistrationSuccess\", {\n code: Schema.String,\n id_token: Schema.String,\n principal: Principal,\n})\n\nexport type RegistrationVerificationResponse = typeof RegistrationVerificationResponse.Type\n\n/* Authentication Options */\n\nexport const AuthenticationOptionsRequest = Schema.Struct({\n allowCredentials: Schema.optionalWith(Schema.Array(Schema.String), { default: () => [] }),\n timeout: Schema.optional(Schema.Number),\n userId: Schema.optional(Schema.String),\n userVerification: Schema.optional(UserVerificationSchema),\n})\n\nexport type AuthenticationOptionsRequest = typeof AuthenticationOptionsRequest.Type\n\n/* Authentication Verification */\n\nexport const AuthenticationVerificationRequest = Schema.Struct({\n response: Schema.Object,\n sessionToken: Schema.String,\n})\n\n// maps to AuthenticationSuccess on the client\nexport const AuthenticationVerificationResponse = Schema.TaggedStruct(\"AuthenticationSuccess\", {\n code: Schema.String,\n id_token: Schema.String,\n principal: Principal,\n})\n\nexport type AuthenticationVerificationResponse = typeof AuthenticationVerificationResponse.Type\n\n/* Passkey */\n\nexport const CredentialDeviceType = [\"singleDevice\", \"multiDevice\"] as const\nexport type CredentialDeviceType = (typeof CredentialDeviceType)[number]\n\nexport const Transports = [\n \"ble\",\n \"hybrid\",\n \"internal\",\n \"nfc\",\n \"usb\",\n \"cable\",\n \"smart-card\",\n] as const\nexport type Transports = (typeof Transports)[number]\n\n/* Passkey */\n\nexport const Passkey = Schema.TaggedStruct(\"Passkey\", {\n createdAt: Schema.Number,\n credential: Schema.Struct({\n aaguid: Schema.String,\n backedUp: Schema.Boolean,\n counter: Schema.Number,\n deviceType: Schema.Literal(...CredentialDeviceType),\n id: Schema.String, // webAuthnId (Base64Url)\n transports: Schema.Array(Schema.Literal(...Transports)),\n userId: Schema.String, // webAuthnUserId (Base64Url)\n }),\n enabled: Schema.Boolean,\n id: Schema.String,\n lastUsed: Schema.optional(Schema.Number),\n platform: Schema.optional(\n Schema.Struct({\n icon: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n })\n ),\n updatedAt: Schema.Number,\n userId: Schema.optional(Schema.String),\n})\n\nexport type Passkey = typeof Passkey.Type\n\nexport const isPasskey = (payload: unknown): payload is Passkey => Schema.is(Passkey)(payload)\n\nexport const PasskeySummary = Schema.TaggedStruct(\"PasskeySummary\", {\n createdAt: Schema.Number,\n credential: Schema.Struct({\n aaguid: Schema.String,\n platformName: Schema.optional(Schema.String),\n }),\n enabled: Schema.Boolean,\n id: Schema.String,\n lastUsed: Schema.optional(Schema.Number),\n userId: Schema.optional(Schema.String),\n})\n\nexport type PasskeySummary = typeof PasskeySummary.Type\n\nexport const isPasskeySummary = (payload: unknown): payload is PasskeySummary =>\n Schema.is(PasskeySummary)(payload)\n\nexport const FindAllPasskeys = Schema.TaggedStruct(\"FindAllPasskeys\", {\n cursor: Schema.NullOr(Schema.String),\n records: Schema.Array(PasskeySummary),\n})\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const Principal: Schema.TaggedStruct<"Principal", {
|
|
3
|
+
id: typeof Schema.String;
|
|
4
|
+
authenticatorId: typeof Schema.String;
|
|
5
|
+
authenticatorType: Schema.Literal<["passkey"]>;
|
|
6
|
+
createdAt: typeof Schema.Number;
|
|
7
|
+
expiresAt: typeof Schema.Number;
|
|
8
|
+
passkey: Schema.optional<Schema.Struct<{
|
|
9
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
10
|
+
userVerified: typeof Schema.Boolean;
|
|
11
|
+
verified: typeof Schema.Boolean;
|
|
12
|
+
}>>;
|
|
13
|
+
userId: typeof Schema.String;
|
|
14
|
+
}>;
|
|
15
|
+
export type Principal = typeof Principal.Type;
|
|
16
|
+
export declare const ExtendedPrincipal: Schema.TaggedStruct<"ExtendedPrincipal", {
|
|
17
|
+
id: typeof Schema.String;
|
|
18
|
+
authenticatorId: typeof Schema.String;
|
|
19
|
+
authenticatorType: Schema.Literal<["passkey"]>;
|
|
20
|
+
createdAt: typeof Schema.Number;
|
|
21
|
+
expiresAt: typeof Schema.Number;
|
|
22
|
+
passkey: Schema.optional<Schema.Struct<{
|
|
23
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
24
|
+
userVerified: typeof Schema.Boolean;
|
|
25
|
+
verified: typeof Schema.Boolean;
|
|
26
|
+
}>>;
|
|
27
|
+
userId: typeof Schema.String;
|
|
28
|
+
metadata: Schema.Struct<{
|
|
29
|
+
ipAddress: Schema.optional<typeof Schema.String>;
|
|
30
|
+
userAgent: Schema.optional<typeof Schema.String>;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
export type ExtendedPrincipal = typeof ExtendedPrincipal.Type;
|
|
34
|
+
export declare const isPrincipal: <I extends true | false>(payload: unknown, extended: I) => payload is I extends true ? ExtendedPrincipal : Principal;
|
|
35
|
+
export declare const IdToken: Schema.TaggedStruct<"IdToken", {
|
|
36
|
+
"a:id": typeof Schema.String;
|
|
37
|
+
"a:typ": typeof Schema.String;
|
|
38
|
+
aud: typeof Schema.String;
|
|
39
|
+
exp: typeof Schema.Number;
|
|
40
|
+
iat: typeof Schema.Number;
|
|
41
|
+
iss: Schema.Literal<["passlock.dev"]>;
|
|
42
|
+
jti: typeof Schema.String;
|
|
43
|
+
"pk:uv": typeof Schema.Boolean;
|
|
44
|
+
sub: typeof Schema.String;
|
|
45
|
+
}>;
|
|
46
|
+
export type IdToken = typeof IdToken.Type;
|
|
47
|
+
export declare const isIdToken: (payload: unknown) => payload is IdToken;
|
|
48
|
+
//# sourceMappingURL=principal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal.d.ts","sourceRoot":"","sources":["../../src/schemas/principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,eAAO,MAAM,SAAS;;;;;;;;;;;;EAcpB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAE7C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAkB5B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAE7D,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,IAAI,GAAG,KAAK,EAChD,SAAS,OAAO,EAChB,UAAU,CAAC,KACV,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,iBAAiB,GAAG,SAIlD,CAAA;AAED,eAAO,MAAM,OAAO;;;;;;;;;;EAUlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,OAAsC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/* Principal */
|
|
3
|
+
export const Principal = Schema.TaggedStruct("Principal", {
|
|
4
|
+
id: Schema.String,
|
|
5
|
+
authenticatorId: Schema.String,
|
|
6
|
+
authenticatorType: Schema.Literal("passkey"),
|
|
7
|
+
createdAt: Schema.Number,
|
|
8
|
+
expiresAt: Schema.Number,
|
|
9
|
+
passkey: Schema.optional(Schema.Struct({
|
|
10
|
+
platformName: Schema.optional(Schema.String),
|
|
11
|
+
userVerified: Schema.Boolean,
|
|
12
|
+
verified: Schema.Boolean,
|
|
13
|
+
})),
|
|
14
|
+
userId: Schema.String,
|
|
15
|
+
});
|
|
16
|
+
export const ExtendedPrincipal = Schema.TaggedStruct("ExtendedPrincipal", {
|
|
17
|
+
id: Schema.String,
|
|
18
|
+
authenticatorId: Schema.String,
|
|
19
|
+
authenticatorType: Schema.Literal("passkey"),
|
|
20
|
+
createdAt: Schema.Number,
|
|
21
|
+
expiresAt: Schema.Number,
|
|
22
|
+
passkey: Schema.optional(Schema.Struct({
|
|
23
|
+
platformName: Schema.optional(Schema.String),
|
|
24
|
+
userVerified: Schema.Boolean,
|
|
25
|
+
verified: Schema.Boolean,
|
|
26
|
+
})),
|
|
27
|
+
userId: Schema.String,
|
|
28
|
+
metadata: Schema.Struct({
|
|
29
|
+
ipAddress: Schema.optional(Schema.String),
|
|
30
|
+
userAgent: Schema.optional(Schema.String),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
export const isPrincipal = (payload, extended) => {
|
|
34
|
+
return extended
|
|
35
|
+
? Schema.is(ExtendedPrincipal)(payload)
|
|
36
|
+
: Schema.is(Schema.Union(Principal, ExtendedPrincipal))(payload);
|
|
37
|
+
};
|
|
38
|
+
export const IdToken = Schema.TaggedStruct("IdToken", {
|
|
39
|
+
"a:id": Schema.String,
|
|
40
|
+
"a:typ": Schema.String,
|
|
41
|
+
aud: Schema.String,
|
|
42
|
+
exp: Schema.Number,
|
|
43
|
+
iat: Schema.Number,
|
|
44
|
+
iss: Schema.Literal("passlock.dev"),
|
|
45
|
+
jti: Schema.String,
|
|
46
|
+
"pk:uv": Schema.Boolean,
|
|
47
|
+
sub: Schema.String,
|
|
48
|
+
});
|
|
49
|
+
export const isIdToken = (payload) => Schema.is(IdToken)(payload);
|
|
50
|
+
//# sourceMappingURL=principal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal.js","sourceRoot":"","sources":["../../src/schemas/principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,eAAe;AAEf,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;IACxD,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,eAAe,EAAE,MAAM,CAAC,MAAM;IAC9B,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,SAAS,EAAE,MAAM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AM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;AACpE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE;IACpD,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM;CACnB,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\n/* Principal */\n\nexport const Principal = Schema.TaggedStruct(\"Principal\", {\n id: Schema.String,\n authenticatorId: Schema.String,\n authenticatorType: Schema.Literal(\"passkey\"),\n createdAt: Schema.Number,\n expiresAt: Schema.Number,\n passkey: Schema.optional(\n Schema.Struct({\n platformName: Schema.optional(Schema.String),\n userVerified: Schema.Boolean,\n verified: Schema.Boolean,\n })\n ),\n userId: Schema.String,\n})\n\nexport type Principal = typeof Principal.Type\n\nexport const ExtendedPrincipal = Schema.TaggedStruct(\"ExtendedPrincipal\", {\n id: Schema.String,\n authenticatorId: Schema.String,\n authenticatorType: Schema.Literal(\"passkey\"),\n createdAt: Schema.Number,\n expiresAt: Schema.Number,\n passkey: Schema.optional(\n Schema.Struct({\n platformName: Schema.optional(Schema.String),\n userVerified: Schema.Boolean,\n verified: Schema.Boolean,\n })\n ),\n userId: Schema.String,\n metadata: Schema.Struct({\n ipAddress: Schema.optional(Schema.String),\n userAgent: Schema.optional(Schema.String),\n }),\n})\n\nexport type ExtendedPrincipal = typeof ExtendedPrincipal.Type\n\nexport const isPrincipal = <I extends true | false>(\n payload: unknown,\n extended: I\n): payload is I extends true ? ExtendedPrincipal : Principal => {\n return extended\n ? Schema.is(ExtendedPrincipal)(payload)\n : Schema.is(Schema.Union(Principal, ExtendedPrincipal))(payload)\n}\n\nexport const IdToken = Schema.TaggedStruct(\"IdToken\", {\n \"a:id\": Schema.String,\n \"a:typ\": Schema.String,\n aud: Schema.String,\n exp: Schema.Number,\n iat: Schema.Number,\n iss: Schema.Literal(\"passlock.dev\"),\n jti: Schema.String,\n \"pk:uv\": Schema.Boolean,\n sub: Schema.String,\n})\n\nexport type IdToken = typeof IdToken.Type\n\nexport const isIdToken = (payload: unknown): payload is IdToken => Schema.is(IdToken)(payload)\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const SignupPayload: Schema.Struct<{
|
|
3
|
+
email: typeof Schema.String;
|
|
4
|
+
firstName: typeof Schema.String;
|
|
5
|
+
lastName: typeof Schema.String;
|
|
6
|
+
}>;
|
|
7
|
+
export type SignupPayload = typeof SignupPayload.Type;
|
|
8
|
+
export declare const TenancyData: Schema.TaggedStruct<"TenancyData", {
|
|
9
|
+
apiKey: Schema.Redacted<typeof Schema.String>;
|
|
10
|
+
tenancyId: typeof Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
export type TenancyData = typeof TenancyData.Type;
|
|
13
|
+
//# sourceMappingURL=signup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../src/schemas/signup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,eAAO,MAAM,aAAa;;;;EAIxB,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD,eAAO,MAAM,WAAW;;;EAGtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export const SignupPayload = Schema.Struct({
|
|
3
|
+
email: Schema.String,
|
|
4
|
+
firstName: Schema.String,
|
|
5
|
+
lastName: Schema.String,
|
|
6
|
+
});
|
|
7
|
+
export const TenancyData = Schema.TaggedStruct("TenancyData", {
|
|
8
|
+
apiKey: Schema.Redacted(Schema.String),
|
|
9
|
+
tenancyId: Schema.String,
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=signup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup.js","sourceRoot":"","sources":["../../src/schemas/signup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM;CACxB,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE;IAC5D,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\nexport const SignupPayload = Schema.Struct({\n email: Schema.String,\n firstName: Schema.String,\n lastName: Schema.String,\n})\n\nexport type SignupPayload = typeof SignupPayload.Type\n\nexport const TenancyData = Schema.TaggedStruct(\"TenancyData\", {\n apiKey: Schema.Redacted(Schema.String),\n tenancyId: Schema.String,\n})\n\nexport type TenancyData = typeof TenancyData.Type\n"]}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
1
|
export interface ApiOptions {
|
|
3
2
|
tenancyId: string;
|
|
4
3
|
/**
|
|
@@ -9,24 +8,6 @@ export interface ApiOptions {
|
|
|
9
8
|
export interface AuthorizedApiOptions extends ApiOptions {
|
|
10
9
|
apiKey: string;
|
|
11
10
|
}
|
|
12
|
-
declare const NotFound_base: Schema.TaggedErrorClass<NotFound, "@error/NotFound", {
|
|
13
|
-
readonly _tag: Schema.tag<"@error/NotFound">;
|
|
14
|
-
} & {
|
|
15
|
-
message: typeof Schema.String;
|
|
16
|
-
}>;
|
|
17
|
-
export declare class NotFound extends NotFound_base {
|
|
18
|
-
static isNotFound: (payload: unknown) => payload is NotFound;
|
|
19
|
-
}
|
|
20
|
-
declare const Unauthorized_base: Schema.TaggedErrorClass<Unauthorized, "@error/Unauthorized", {
|
|
21
|
-
readonly _tag: Schema.tag<"@error/Unauthorized">;
|
|
22
|
-
}>;
|
|
23
|
-
export declare class Unauthorized extends Unauthorized_base {
|
|
24
|
-
}
|
|
25
|
-
declare const Forbidden_base: Schema.TaggedErrorClass<Forbidden, "@error/Forbidden", {
|
|
26
|
-
readonly _tag: Schema.tag<"@error/Forbidden">;
|
|
27
|
-
}>;
|
|
28
|
-
export declare class Forbidden extends Forbidden_base {
|
|
29
|
-
}
|
|
30
11
|
export declare class UnexpectedError extends Error {
|
|
31
12
|
readonly _tag: string;
|
|
32
13
|
constructor(data: {
|
|
@@ -35,5 +16,4 @@ export declare class UnexpectedError extends Error {
|
|
|
35
16
|
});
|
|
36
17
|
readonly toString: () => string;
|
|
37
18
|
}
|
|
38
|
-
export {};
|
|
39
19
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAKnD,SAAkB,QAAQ,QAAO,MAAM,CAA0C;CAClF"}
|
package/dist/shared.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
export class NotFound extends Schema.TaggedError("@error/NotFound")("@error/NotFound", {
|
|
3
|
-
message: Schema.String,
|
|
4
|
-
}) {
|
|
5
|
-
static isNotFound = (payload) => Schema.is(NotFound)(payload);
|
|
6
|
-
}
|
|
7
|
-
// Define a schema for the "Unauthorized" error
|
|
8
|
-
export class Unauthorized extends Schema.TaggedError()("@error/Unauthorized", {}) {
|
|
9
|
-
}
|
|
10
|
-
// Define a schema for the "Unauthorized" error
|
|
11
|
-
export class Forbidden extends Schema.TaggedError()("@error/Forbidden", {}) {
|
|
12
|
-
}
|
|
13
1
|
export class UnexpectedError extends Error {
|
|
14
2
|
_tag;
|
|
15
3
|
constructor(data) {
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAQ;IAErB,YAAY,IAAuC;QACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAEiB,QAAQ,GAAG,GAAW,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,IAAI,GAAG,CAAA;CAClF","sourcesContent":["export interface ApiOptions {\n tenancyId: string\n /**\n * @default https://api.passlock.dev\n */\n endpoint?: string\n}\n\nexport interface AuthorizedApiOptions extends ApiOptions {\n apiKey: string\n}\n\nexport class UnexpectedError extends Error {\n readonly _tag: string\n\n constructor(data: { _tag: string; message: string }) {\n super(data.message)\n this._tag = data._tag\n }\n\n override readonly toString = (): string => `${this.message} (_tag: ${this._tag})`\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HeadersInit } from "@effect/platform-node/Undici";
|
|
2
|
+
import { Effect, Redacted } from "effect";
|
|
3
|
+
export declare const intTestConfig: Effect.Effect<{
|
|
4
|
+
tenancyId: string;
|
|
5
|
+
passkeyId: string;
|
|
6
|
+
code: string;
|
|
7
|
+
apiKey: Redacted.Redacted<string>;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
}, import("effect/ConfigError").ConfigError, never>;
|
|
10
|
+
export declare const getHeaderValue: (headers: HeadersInit, header: string) => string | null;
|
|
11
|
+
//# sourceMappingURL=testUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAAiB,MAAM,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAkBtE,eAAO,MAAM,aAAa;;;;;;mDAQxB,CAAA;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IAc9E,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Headers } from "@effect/platform-node/Undici";
|
|
2
|
+
import { Array, Config, Effect, Option, pipe, Redacted } from "effect";
|
|
3
|
+
const lookupTenancyId = pipe(Config.string("PASSLOCK_TENANCY_ID"), Config.withDefault("itTenancy"));
|
|
4
|
+
const lookupPasskeyId = pipe(Config.string("PASSLOCK_PASSKEY_ID"), Config.withDefault("itPasskey"));
|
|
5
|
+
const lookupCode = pipe(Config.string("PASSLOCK_PRINCIPAL_CODE"), Config.withDefault("itPrincipal"));
|
|
6
|
+
const lookupApiKey = pipe(Config.redacted("PASSLOCK_API_KEY"), Config.withDefault(Redacted.make("itApiKey")));
|
|
7
|
+
const lookupEndpoint = pipe(Config.string("PASSLOCK_ENDPOINT"), Config.withDefault("http://localhost:3000"));
|
|
8
|
+
export const intTestConfig = Effect.gen(function* () {
|
|
9
|
+
const tenancyId = yield* lookupTenancyId;
|
|
10
|
+
const passkeyId = yield* lookupPasskeyId;
|
|
11
|
+
const code = yield* lookupCode;
|
|
12
|
+
const apiKey = yield* lookupApiKey;
|
|
13
|
+
const endpoint = yield* lookupEndpoint;
|
|
14
|
+
return { tenancyId, passkeyId, code, apiKey, endpoint };
|
|
15
|
+
});
|
|
16
|
+
export const getHeaderValue = (headers, header) => {
|
|
17
|
+
if (headers instanceof Headers) {
|
|
18
|
+
return headers.get(header);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(headers)) {
|
|
21
|
+
return pipe(Array.findFirst(headers, ([k]) => k === header), Option.map(([_, v]) => v), Option.getOrNull);
|
|
22
|
+
}
|
|
23
|
+
return headers["authorization"] ?? null;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=testUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAA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,EAAE,QAAQ,EAAE,CAAA;AACzD,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAE,MAAc,EAAiB,EAAE;IACpF,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CACT,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,EAC/C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EACzB,MAAM,CAAC,SAAS,CACjB,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,eAAe,CAAC,IAAI,IAAI,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import { Headers, type HeadersInit } from \"@effect/platform-node/Undici\"\nimport { Array, Config, Effect, Option, pipe, Redacted } from \"effect\"\n\nconst lookupTenancyId = pipe(Config.string(\"PASSLOCK_TENANCY_ID\"), Config.withDefault(\"itTenancy\"))\n\nconst lookupPasskeyId = pipe(Config.string(\"PASSLOCK_PASSKEY_ID\"), Config.withDefault(\"itPasskey\"))\n\nconst lookupCode = pipe(Config.string(\"PASSLOCK_PRINCIPAL_CODE\"), Config.withDefault(\"itPrincipal\"))\n\nconst lookupApiKey = pipe(\n Config.redacted(\"PASSLOCK_API_KEY\"),\n Config.withDefault(Redacted.make(\"itApiKey\"))\n)\n\nconst lookupEndpoint = pipe(\n Config.string(\"PASSLOCK_ENDPOINT\"),\n Config.withDefault(\"http://localhost:3000\")\n)\n\nexport const intTestConfig = Effect.gen(function* () {\n const tenancyId = yield* lookupTenancyId\n const passkeyId = yield* lookupPasskeyId\n const code = yield* lookupCode\n const apiKey = yield* lookupApiKey\n const endpoint = yield* lookupEndpoint\n\n return { tenancyId, passkeyId, code, apiKey, endpoint }\n})\n\nexport const getHeaderValue = (headers: HeadersInit, header: string): string | null => {\n if (headers instanceof Headers) {\n return headers.get(header)\n }\n\n if (Array.isArray(headers)) {\n return pipe(\n Array.findFirst(headers, ([k]) => k === header),\n Option.map(([_, v]) => v),\n Option.getOrNull\n )\n }\n\n return headers[\"authorization\"] ?? null\n}\n"]}
|