@passlock/server 2.1.0
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/README.md +45 -0
- package/README.template.md +45 -0
- package/dist/effect.d.ts +7 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +4 -0
- package/dist/effect.js.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +30 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/network.d.ts +134 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +172 -0
- package/dist/network.js.map +1 -0
- package/dist/passkey/passkey.d.ts +132 -0
- package/dist/passkey/passkey.d.ts.map +1 -0
- package/dist/passkey/passkey.js +158 -0
- package/dist/passkey/passkey.js.map +1 -0
- package/dist/principal/principal.d.ts +22 -0
- package/dist/principal/principal.d.ts.map +1 -0
- package/dist/principal/principal.js +65 -0
- package/dist/principal/principal.js.map +1 -0
- package/dist/safe.d.ts +154 -0
- package/dist/safe.d.ts.map +1 -0
- package/dist/safe.js +147 -0
- package/dist/safe.js.map +1 -0
- package/dist/schemas/errors.d.ts +2 -0
- package/dist/schemas/errors.d.ts.map +1 -0
- package/dist/schemas/errors.js +72 -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 +85 -0
- package/dist/schemas/passkey.d.ts.map +1 -0
- package/dist/schemas/passkey.js +64 -0
- package/dist/schemas/passkey.js.map +1 -0
- package/dist/schemas/principal.d.ts +88 -0
- package/dist/schemas/principal.d.ts.map +1 -0
- package/dist/schemas/principal.js +46 -0
- package/dist/schemas/principal.js.map +1 -0
- package/dist/schemas/satisfy.d.ts +2 -0
- package/dist/schemas/satisfy.d.ts.map +1 -0
- package/dist/schemas/satisfy.js +2 -0
- package/dist/schemas/satisfy.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 +19 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +9 -0
- package/dist/shared.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/*
|
|
3
|
+
* Important. We don't use `type X = typeof X.Type` because it won't generate
|
|
4
|
+
* the Typedoc docs, so instead we mirror the types and use a dummy
|
|
5
|
+
* `type _x = satisfy<typeof X.Type, X>`
|
|
6
|
+
* kind of a type level satisfies
|
|
7
|
+
*/
|
|
8
|
+
/* Registration Options */
|
|
9
|
+
export const UserVerification = Schema.Literal("required", "preferred", "discouraged");
|
|
10
|
+
/* Passkey */
|
|
11
|
+
export const CredentialDeviceType = ["singleDevice", "multiDevice"];
|
|
12
|
+
export const Transports = [
|
|
13
|
+
"ble",
|
|
14
|
+
"hybrid",
|
|
15
|
+
"internal",
|
|
16
|
+
"nfc",
|
|
17
|
+
"usb",
|
|
18
|
+
"cable",
|
|
19
|
+
"smart-card",
|
|
20
|
+
];
|
|
21
|
+
/* Passkey */
|
|
22
|
+
export const Passkey = Schema.TaggedStruct("Passkey", {
|
|
23
|
+
id: Schema.String,
|
|
24
|
+
userId: Schema.optional(Schema.String),
|
|
25
|
+
enabled: Schema.Boolean,
|
|
26
|
+
credential: Schema.Struct({
|
|
27
|
+
id: Schema.String, // webAuthnId (Base64Url)
|
|
28
|
+
userId: Schema.String, // webAuthnUserId (Base64Url)
|
|
29
|
+
username: Schema.String,
|
|
30
|
+
aaguid: Schema.String,
|
|
31
|
+
backedUp: Schema.Boolean,
|
|
32
|
+
counter: Schema.Number,
|
|
33
|
+
deviceType: Schema.Literal(...CredentialDeviceType),
|
|
34
|
+
transports: Schema.Array(Schema.Literal(...Transports)),
|
|
35
|
+
publicKey: Schema.Uint8ArrayFromBase64Url,
|
|
36
|
+
rpId: Schema.String,
|
|
37
|
+
}),
|
|
38
|
+
platform: Schema.optional(Schema.Struct({
|
|
39
|
+
icon: Schema.optional(Schema.String),
|
|
40
|
+
name: Schema.optional(Schema.String),
|
|
41
|
+
})),
|
|
42
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
43
|
+
createdAt: Schema.Number,
|
|
44
|
+
updatedAt: Schema.Number,
|
|
45
|
+
});
|
|
46
|
+
export const PasskeySummary = Schema.TaggedStruct("PasskeySummary", {
|
|
47
|
+
id: Schema.String,
|
|
48
|
+
userId: Schema.String,
|
|
49
|
+
credential: Schema.Struct({
|
|
50
|
+
id: Schema.String,
|
|
51
|
+
userId: Schema.String,
|
|
52
|
+
}),
|
|
53
|
+
enabled: Schema.Boolean,
|
|
54
|
+
createdAt: Schema.Number,
|
|
55
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
56
|
+
});
|
|
57
|
+
export const FindAllPasskeys = Schema.TaggedStruct("FindAllPasskeys", {
|
|
58
|
+
cursor: Schema.NullOr(Schema.String),
|
|
59
|
+
records: Schema.Array(PasskeySummary),
|
|
60
|
+
});
|
|
61
|
+
export const UpdatedPasskeys = Schema.TaggedStruct("UpdatedPasskeys", {
|
|
62
|
+
updated: Schema.Array(Passkey),
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=passkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/schemas/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AAEH,0BAA0B;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAC5C,UAAU,EACV,WAAW,EACX,aAAa,CAC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CAAC,MAAM,CAAC,MAAM,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;IAClE,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;QACxB,EAAE,EAAE,MAAM,CAAC,MAAM;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACzC,CAAC,CAAA;AAIF,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;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACpE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;CAC/B,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\n/*\n * Important. We don't use `type X = typeof X.Type` because it won't generate\n * the Typedoc docs, so instead we mirror the types and use a dummy\n * `type _x = satisfy<typeof X.Type, X>`\n * kind of a type level satisfies\n */\n\n/* Registration Options */\n\nexport const UserVerification = Schema.Literal(\n \"required\",\n \"preferred\",\n \"discouraged\"\n)\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 id: Schema.String,\n userId: Schema.optional(Schema.String),\n enabled: Schema.Boolean,\n credential: Schema.Struct({\n id: Schema.String, // webAuthnId (Base64Url)\n userId: Schema.String, // webAuthnUserId (Base64Url)\n username: Schema.String,\n aaguid: Schema.String,\n backedUp: Schema.Boolean,\n counter: Schema.Number,\n deviceType: Schema.Literal(...CredentialDeviceType),\n transports: Schema.Array(Schema.Literal(...Transports)),\n publicKey: Schema.Uint8ArrayFromBase64Url,\n rpId: Schema.String,\n }),\n platform: Schema.optional(\n Schema.Struct({\n icon: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n })\n ),\n lastUsed: Schema.optional(Schema.Number),\n createdAt: Schema.Number,\n updatedAt: Schema.Number,\n})\n\nexport type Passkey = typeof Passkey.Type\n\nexport type PasskeyEncoded = typeof Passkey.Encoded\n\nexport const PasskeySummary = Schema.TaggedStruct(\"PasskeySummary\", {\n id: Schema.String,\n userId: Schema.String,\n credential: Schema.Struct({\n id: Schema.String,\n userId: Schema.String,\n }),\n enabled: Schema.Boolean,\n createdAt: Schema.Number,\n lastUsed: Schema.optional(Schema.Number),\n})\n\nexport type PasskeySummary = typeof PasskeySummary.Type\n\nexport const FindAllPasskeys = Schema.TaggedStruct(\"FindAllPasskeys\", {\n cursor: Schema.NullOr(Schema.String),\n records: Schema.Array(PasskeySummary),\n})\n\nexport const UpdatedPasskeys = Schema.TaggedStruct(\"UpdatedPasskeys\", {\n updated: Schema.Array(Passkey),\n})\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const PrincipalSchema: 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
|
+
userVerified: typeof Schema.Boolean;
|
|
10
|
+
verified: typeof Schema.Boolean;
|
|
11
|
+
}>>;
|
|
12
|
+
userId: typeof Schema.String;
|
|
13
|
+
}>;
|
|
14
|
+
export type Principal = {
|
|
15
|
+
readonly _tag: "Principal";
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly userId: string;
|
|
18
|
+
readonly createdAt: number;
|
|
19
|
+
readonly authenticatorId: string;
|
|
20
|
+
readonly authenticatorType: "passkey";
|
|
21
|
+
readonly passkey?: {
|
|
22
|
+
readonly userVerified: boolean;
|
|
23
|
+
readonly verified: boolean;
|
|
24
|
+
} | undefined;
|
|
25
|
+
readonly expiresAt: number;
|
|
26
|
+
};
|
|
27
|
+
export declare const isPrincipal: (payload: unknown) => payload is Principal;
|
|
28
|
+
export declare const ExtendedPrincipalSchema: Schema.TaggedStruct<"ExtendedPrincipal", {
|
|
29
|
+
id: typeof Schema.String;
|
|
30
|
+
authenticatorId: typeof Schema.String;
|
|
31
|
+
authenticatorType: Schema.Literal<["passkey"]>;
|
|
32
|
+
createdAt: typeof Schema.Number;
|
|
33
|
+
expiresAt: typeof Schema.Number;
|
|
34
|
+
passkey: Schema.optional<Schema.Struct<{
|
|
35
|
+
platformName: Schema.optional<typeof Schema.String>;
|
|
36
|
+
userVerified: typeof Schema.Boolean;
|
|
37
|
+
verified: typeof Schema.Boolean;
|
|
38
|
+
}>>;
|
|
39
|
+
userId: typeof Schema.String;
|
|
40
|
+
metadata: Schema.Struct<{
|
|
41
|
+
ipAddress: Schema.optional<typeof Schema.String>;
|
|
42
|
+
userAgent: Schema.optional<typeof Schema.String>;
|
|
43
|
+
}>;
|
|
44
|
+
}>;
|
|
45
|
+
export type ExtendedPrincipal = {
|
|
46
|
+
readonly _tag: "ExtendedPrincipal";
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly authenticatorId: string;
|
|
49
|
+
readonly authenticatorType: "passkey";
|
|
50
|
+
readonly passkey?: {
|
|
51
|
+
readonly userVerified: boolean;
|
|
52
|
+
readonly verified: boolean;
|
|
53
|
+
readonly platformName?: string | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
readonly createdAt: number;
|
|
56
|
+
readonly expiresAt: number;
|
|
57
|
+
readonly userId: string;
|
|
58
|
+
readonly metadata: {
|
|
59
|
+
readonly ipAddress?: string | undefined;
|
|
60
|
+
readonly userAgent?: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare const isExtendedPrincipal: (payload: unknown) => payload is ExtendedPrincipal;
|
|
64
|
+
export declare const IdTokenSchema: Schema.TaggedStruct<"IdToken", {
|
|
65
|
+
"a:id": typeof Schema.String;
|
|
66
|
+
"a:typ": typeof Schema.String;
|
|
67
|
+
aud: typeof Schema.String;
|
|
68
|
+
exp: typeof Schema.Number;
|
|
69
|
+
iat: typeof Schema.Number;
|
|
70
|
+
iss: Schema.Literal<["passlock.dev"]>;
|
|
71
|
+
jti: typeof Schema.String;
|
|
72
|
+
"pk:uv": typeof Schema.Boolean;
|
|
73
|
+
sub: typeof Schema.String;
|
|
74
|
+
}>;
|
|
75
|
+
export type IdToken = {
|
|
76
|
+
readonly "a:id": string;
|
|
77
|
+
readonly "a:typ": string;
|
|
78
|
+
readonly aud: string;
|
|
79
|
+
readonly exp: number;
|
|
80
|
+
readonly iat: number;
|
|
81
|
+
readonly iss: "passlock.dev";
|
|
82
|
+
readonly jti: string;
|
|
83
|
+
readonly "pk:uv": boolean;
|
|
84
|
+
readonly sub: string;
|
|
85
|
+
readonly _tag: "IdToken";
|
|
86
|
+
};
|
|
87
|
+
export declare const isIdToken: (payload: unknown) => payload is IdToken;
|
|
88
|
+
//# sourceMappingURL=principal.d.ts.map
|
|
@@ -0,0 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S,CAAA;IACb,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACxC,CAAA;CACF,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,SAAS,OAAO,KACf,OAAO,IAAI,iBAAgE,CAAA;AAO9E,eAAO,MAAM,aAAa;;;;;;;;;;EAUxB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAA;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,OACrB,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/* Principal */
|
|
3
|
+
export const PrincipalSchema = 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
|
+
userVerified: Schema.Boolean,
|
|
11
|
+
verified: Schema.Boolean,
|
|
12
|
+
})),
|
|
13
|
+
userId: Schema.String,
|
|
14
|
+
});
|
|
15
|
+
export const isPrincipal = (payload) => Schema.is(PrincipalSchema)(payload);
|
|
16
|
+
export const ExtendedPrincipalSchema = 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 isExtendedPrincipal = (payload) => Schema.is(ExtendedPrincipalSchema)(payload);
|
|
34
|
+
export const IdTokenSchema = Schema.TaggedStruct("IdToken", {
|
|
35
|
+
"a:id": Schema.String,
|
|
36
|
+
"a:typ": Schema.String,
|
|
37
|
+
aud: Schema.String,
|
|
38
|
+
exp: Schema.Number,
|
|
39
|
+
iat: Schema.Number,
|
|
40
|
+
iss: Schema.Literal("passlock.dev"),
|
|
41
|
+
jti: Schema.String,
|
|
42
|
+
"pk:uv": Schema.Boolean,
|
|
43
|
+
sub: Schema.String,
|
|
44
|
+
});
|
|
45
|
+
export const isIdToken = (payload) => Schema.is(IdTokenSchema)(payload);
|
|
46
|
+
//# sourceMappingURL=principal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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B,CAAC,CACH;IACD,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QACzC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;KAC1C,CAAC;CACH,CACF,CAAA;AAuBD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EACc,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,CAAA;AAO9E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE;IAC1D,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;AAeF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE,CAChE,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\nimport type { satisfy } from \"./satisfy.js\"\n\n/* Principal */\n\nexport const PrincipalSchema = 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 userVerified: Schema.Boolean,\n verified: Schema.Boolean,\n })\n ),\n userId: Schema.String,\n})\n\nexport type Principal = {\n readonly _tag: \"Principal\"\n readonly id: string\n readonly userId: string\n readonly createdAt: number\n readonly authenticatorId: string\n readonly authenticatorType: \"passkey\"\n readonly passkey?:\n | {\n readonly userVerified: boolean\n readonly verified: boolean\n }\n | undefined\n readonly expiresAt: number\n}\n\nexport const isPrincipal = (payload: unknown): payload is Principal =>\n Schema.is(PrincipalSchema)(payload)\n\ntype _Principal = satisfy<typeof PrincipalSchema.Type, Principal>\n\nexport const ExtendedPrincipalSchema = Schema.TaggedStruct(\n \"ExtendedPrincipal\",\n {\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)\n\nexport type ExtendedPrincipal = {\n readonly _tag: \"ExtendedPrincipal\"\n readonly id: string\n readonly authenticatorId: string\n readonly authenticatorType: \"passkey\"\n readonly passkey?:\n | {\n readonly userVerified: boolean\n readonly verified: boolean\n readonly platformName?: string | undefined\n }\n | undefined\n readonly createdAt: number\n readonly expiresAt: number\n readonly userId: string\n readonly metadata: {\n readonly ipAddress?: string | undefined\n readonly userAgent?: string | undefined\n }\n}\n\nexport const isExtendedPrincipal = (\n payload: unknown\n): payload is ExtendedPrincipal => Schema.is(ExtendedPrincipalSchema)(payload)\n\ntype _ExtendedPrincipal = satisfy<\n typeof ExtendedPrincipalSchema.Type,\n ExtendedPrincipal\n>\n\nexport const IdTokenSchema = 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 = {\n readonly \"a:id\": string\n readonly \"a:typ\": string\n readonly aud: string\n readonly exp: number\n readonly iat: number\n readonly iss: \"passlock.dev\"\n readonly jti: string\n readonly \"pk:uv\": boolean\n readonly sub: string\n readonly _tag: \"IdToken\"\n}\n\nexport const isIdToken = (payload: unknown): payload is IdToken =>\n Schema.is(IdTokenSchema)(payload)\n\ntype _IdToken = satisfy<typeof IdTokenSchema.Type, IdToken>\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satisfy.d.ts","sourceRoot":"","sources":["../../src/schemas/satisfy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,IAAI,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satisfy.js","sourceRoot":"","sources":["../../src/schemas/satisfy.ts"],"names":[],"mappings":"","sourcesContent":["export type satisfy<base, t extends base> = t\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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PasslockOptions = {
|
|
2
|
+
tenancyId: string;
|
|
3
|
+
/**
|
|
4
|
+
* @default https://api.passlock.dev
|
|
5
|
+
*/
|
|
6
|
+
endpoint?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface AuthenticatedOptions extends PasslockOptions {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class UnexpectedError extends Error {
|
|
12
|
+
readonly _tag: string;
|
|
13
|
+
constructor(data: {
|
|
14
|
+
_tag: string;
|
|
15
|
+
message: string;
|
|
16
|
+
});
|
|
17
|
+
readonly toString: () => string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,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,CACC;CACzC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAaA,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,CACxC,GAAG,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,IAAI,GAAG,CAAA;CACzC","sourcesContent":["export type PasslockOptions = {\n tenancyId: string\n\n /**\n * @default https://api.passlock.dev\n */\n endpoint?: string\n}\n\nexport interface AuthenticatedOptions extends PasslockOptions {\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 =>\n `${this.message} (_tag: ${this._tag})`\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@passlock/server",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Passkey authentication library for Fetch capable backends (Node, Bun, Vercel, Cloudflare workers etc.)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"passkey",
|
|
7
|
+
"webauthn",
|
|
8
|
+
"node",
|
|
9
|
+
"Bun",
|
|
10
|
+
"Vercel",
|
|
11
|
+
"CF Workers"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://passlock.dev",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/passlock-dev/passlock/issues",
|
|
16
|
+
"email": "team@passlock.dev"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/passlock-dev/passlock.git",
|
|
21
|
+
"directory": "packages/server"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Toby Hobson",
|
|
26
|
+
"email": "toby@passlock.dev"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./safe": {
|
|
36
|
+
"types": "./dist/safe.d.ts",
|
|
37
|
+
"import": "./dist/safe.js",
|
|
38
|
+
"default": "./dist/safe.js"
|
|
39
|
+
},
|
|
40
|
+
"./effect": {
|
|
41
|
+
"types": "./dist/effect.d.ts",
|
|
42
|
+
"import": "./dist/effect.js",
|
|
43
|
+
"default": "./dist/effect.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"module": "./dist/index.js",
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"!dist/**/*.test.*",
|
|
51
|
+
"!dist/**/*.spec.*"
|
|
52
|
+
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"effect": "3.19.19",
|
|
55
|
+
"jose": "^6.2.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@biomejs/biome": "^2.4.6",
|
|
59
|
+
"@effect/vitest": "^0.27.0",
|
|
60
|
+
"globals": "^17.4.0",
|
|
61
|
+
"npm-check-updates": "^19.6.3",
|
|
62
|
+
"publint": "0.3.18",
|
|
63
|
+
"rimraf": "^6.1.3",
|
|
64
|
+
"tsx": "4.21.0",
|
|
65
|
+
"typedoc": "^0.28.17",
|
|
66
|
+
"typescript": "^5.9.3",
|
|
67
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
68
|
+
"vitest": "^3.2.4"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=20"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "tsc -p tsconfig.build.json",
|
|
75
|
+
"build:clean": "$npm_execpath run clean:full && $npm_execpath run build",
|
|
76
|
+
"build:production": "$npm_execpath run build:clean && $npm_execpath run build:readme && $npm_execpath run replaceTokens && echo '' && publint",
|
|
77
|
+
"build:readme": "VERSION=${npm_package_version} tsx ../../scripts/replace-readme-tokens.ts ./packages/server",
|
|
78
|
+
"typedoc": "typedoc",
|
|
79
|
+
"clean": "tsc -p tsconfig.build.json --clean",
|
|
80
|
+
"clean:full": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
81
|
+
"replaceTokens": "VERSION=${npm_package_version} tsx ../../scripts/replace-tokens.ts ./packages/server",
|
|
82
|
+
"test:unit": "vitest --project unit run",
|
|
83
|
+
"test:unit:watch": "vitest --project unit",
|
|
84
|
+
"test:integration": "vitest --project integration run",
|
|
85
|
+
"test:all": "vitest --project unit --project integration run",
|
|
86
|
+
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
87
|
+
"lint": "biome check .",
|
|
88
|
+
"lint:fix": "biome check --fix .",
|
|
89
|
+
"lint:ci": "biome ci .",
|
|
90
|
+
"format": "biome format --fix .",
|
|
91
|
+
"format:check": "biome format ."
|
|
92
|
+
}
|
|
93
|
+
}
|