@passlock/node 2.0.0-beta.2 → 2.0.0-beta.5
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 +24 -0
- package/dist/passkey/effects.d.ts.map +1 -0
- package/dist/passkey/effects.js +87 -0
- package/dist/passkey/effects.js.map +1 -0
- package/dist/passkey/index.d.ts +64 -0
- package/dist/passkey/index.d.ts.map +1 -0
- package/dist/passkey/index.js +58 -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 +63 -0
- package/dist/schemas/passkey.d.ts.map +1 -0
- package/dist/schemas/passkey.js +59 -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 +46 -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 +4 -22
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +2 -11
- 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 +26 -27
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/principal/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/principal/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAEL,YAAY,IAAI,aAAa,EAG7B,aAAa,IAAI,cAAc,GAChC,MAAM,cAAc,CAAA;AAErB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAY,EACZ,OAA4B,EAC0B,EAAE,CACxD,IAAI,CACF,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAC5B,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EACrC,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAY,EACZ,OAA4B,EACA,EAAE,CAC9B,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE9F;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAa,EACb,OAA2B,EACe,EAAE,CAC5C,IAAI,CACF,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAC9B,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAa,EACb,OAA2B,EACP,EAAE,CACtB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAShG,cAAc,yBAAyB,CAAA","sourcesContent":["import type { Forbidden, InvalidCode } from \"../schemas/errors.js\"\nimport type { ExtendedPrincipal, Principal } from \"../schemas/principal.js\"\nimport { FetchHttpClient } from \"@effect/platform\"\nimport { Effect, identity, pipe } from \"effect\"\nimport {\n type ExchangeCodeOptions,\n exchangeCode as exchangeCodeE,\n type VerificationFailure,\n type VerifyTokenOptions,\n verifyIdToken as verifyIdTokenE,\n} from \"./effects.js\"\n\n/**\n * Call the Passlock backend API to exchange a code for a Principal\n * @param code\n * @package options\n * @returns\n */\nexport const exchangeCode = (\n code: string,\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal | Forbidden | InvalidCode> =>\n pipe(\n exchangeCodeE(code, options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.provide(FetchHttpClient.layer),\n Effect.runPromise\n )\n\n/**\n * Call the Passlock backend API to exchange a code for a Principal\n * @param code\n * @package options\n * @returns\n */\nexport const exchangeCodeUnsafe = (\n code: string,\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> =>\n pipe(exchangeCodeE(code, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\n\n/**\n * Decode and verify a Passlock idToken.\n * Note: This will make a network call to the passlock.dev/.well-known/jwks.json\n * endpoint to fetch the relevant public key. The response will be cached, however\n * bear in mind that for something like AWS lambda it will make the call on every\n * cold start so might actually be slower than {@link exchangeCode}\n * @param token\n * @param options\n * @returns\n */\nexport const verifyIdToken = (\n token: string,\n options: VerifyTokenOptions\n): Promise<Principal | VerificationFailure> =>\n pipe(\n verifyIdTokenE(token, options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Decode and verify a Passlock idToken.\n * Note: This will make a network call to the passlock.dev/.well-known/jwks.json\n * endpoint to fetch the relevant public key. The response will be cached, however\n * bear in mind that for something like AWS lambda it will make the call on every\n * cold start so might actually be slower than {@link exchangeCode}\n * @param token\n * @param options\n * @returns\n */\nexport const verifyIdTokenUnsafe = (\n token: string,\n options: VerifyTokenOptions\n): Promise<Principal> =>\n pipe(verifyIdTokenE(token, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\n\nexport type { InvalidCode } from \"../schemas/errors.js\"\nexport type {\n ExchangeCodeOptions,\n Principal,\n VerificationFailure,\n VerifyTokenOptions,\n} from \"./effects.js\"\nexport * from \"../schemas/principal.js\"\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const Unauthorized_base: Schema.TaggedErrorClass<Unauthorized, "@error/Unauthorized", {
|
|
3
|
+
readonly _tag: Schema.tag<"@error/Unauthorized">;
|
|
4
|
+
}>;
|
|
5
|
+
export declare class Unauthorized extends Unauthorized_base {
|
|
6
|
+
}
|
|
7
|
+
declare const Forbidden_base: Schema.TaggedErrorClass<Forbidden, "@error/Forbidden", {
|
|
8
|
+
readonly _tag: Schema.tag<"@error/Forbidden">;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class Forbidden extends Forbidden_base {
|
|
11
|
+
}
|
|
12
|
+
declare const InvalidCode_base: Schema.TaggedErrorClass<InvalidCode, "@error/InvalidCode", {
|
|
13
|
+
readonly _tag: Schema.tag<"@error/InvalidCode">;
|
|
14
|
+
} & {
|
|
15
|
+
message: typeof Schema.String;
|
|
16
|
+
}>;
|
|
17
|
+
export declare class InvalidCode extends InvalidCode_base {
|
|
18
|
+
}
|
|
19
|
+
declare const InvalidTenancy_base: Schema.TaggedErrorClass<InvalidTenancy, "@error/InvalidTenancy", {
|
|
20
|
+
readonly _tag: Schema.tag<"@error/InvalidTenancy">;
|
|
21
|
+
} & {
|
|
22
|
+
message: typeof Schema.String;
|
|
23
|
+
}>;
|
|
24
|
+
export declare class InvalidTenancy extends InvalidTenancy_base {
|
|
25
|
+
}
|
|
26
|
+
declare const PasskeyNotFound_base: Schema.TaggedErrorClass<PasskeyNotFound, "@error/PasskeyNotFound", {
|
|
27
|
+
readonly _tag: Schema.tag<"@error/PasskeyNotFound">;
|
|
28
|
+
} & {
|
|
29
|
+
credentialId: typeof Schema.String;
|
|
30
|
+
message: typeof Schema.String;
|
|
31
|
+
rpId: typeof Schema.String;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* We need the credentialId and rpId to feed into the
|
|
35
|
+
* client's signalCredentialRemoval function
|
|
36
|
+
*/
|
|
37
|
+
export declare class PasskeyNotFound extends PasskeyNotFound_base {
|
|
38
|
+
}
|
|
39
|
+
declare const NotFound_base: Schema.TaggedErrorClass<NotFound, "@error/NotFound", {
|
|
40
|
+
readonly _tag: Schema.tag<"@error/NotFound">;
|
|
41
|
+
} & {
|
|
42
|
+
message: typeof Schema.String;
|
|
43
|
+
}>;
|
|
44
|
+
export declare class NotFound extends NotFound_base {
|
|
45
|
+
}
|
|
46
|
+
declare const InvalidEmail_base: Schema.TaggedErrorClass<InvalidEmail, "@error/InvalidEmail", {
|
|
47
|
+
readonly _tag: Schema.tag<"@error/InvalidEmail">;
|
|
48
|
+
} & {
|
|
49
|
+
message: typeof Schema.String;
|
|
50
|
+
}>;
|
|
51
|
+
export declare class InvalidEmail extends InvalidEmail_base {
|
|
52
|
+
}
|
|
53
|
+
declare const DuplicateEmail_base: Schema.TaggedErrorClass<DuplicateEmail, "@error/DuplicateEmail", {
|
|
54
|
+
readonly _tag: Schema.tag<"@error/DuplicateEmail">;
|
|
55
|
+
} & {
|
|
56
|
+
message: typeof Schema.String;
|
|
57
|
+
}>;
|
|
58
|
+
export declare class DuplicateEmail extends DuplicateEmail_base {
|
|
59
|
+
}
|
|
60
|
+
declare const BadRequest_base: Schema.TaggedErrorClass<BadRequest, "@error/BadRequest", {
|
|
61
|
+
readonly _tag: Schema.tag<"@error/BadRequest">;
|
|
62
|
+
} & {
|
|
63
|
+
message: typeof Schema.String;
|
|
64
|
+
}>;
|
|
65
|
+
export declare class BadRequest extends BadRequest_base {
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;AAE/B,qBAAa,YAAa,SAAQ,iBAA6D;CAAG;;;;AAElG,qBAAa,SAAU,SAAQ,cAAuD;CAAG;;;;;;AAEzF,qBAAa,WAAY,SAAQ,gBAKhC;CAAG;;;;;;AAEJ,qBAAa,cAAe,SAAQ,mBAElC;CAAG;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAOpC;CAAG;;;;;;AAEJ,qBAAa,QAAS,SAAQ,aAE5B;CAAG;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAGjC;CAAG;;;;;;AAEJ,qBAAa,cAAe,SAAQ,mBAGnC;CAAG;;;;;;AAEJ,qBAAa,UAAW,SAAQ,eAG/B;CAAG"}
|
|
@@ -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
|
+
//# sourceMapp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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,63 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const UserVerificationSchema: Schema.Literal<["required", "preferred", "discouraged"]>;
|
|
3
|
+
export declare const CredentialDeviceType: readonly ["singleDevice", "multiDevice"];
|
|
4
|
+
export type CredentialDeviceType = (typeof CredentialDeviceType)[number];
|
|
5
|
+
export declare const Transports: readonly ["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"];
|
|
6
|
+
export type Transports = (typeof Transports)[number];
|
|
7
|
+
export declare const Passkey: Schema.TaggedStruct<"Passkey", {
|
|
8
|
+
createdAt: typeof Schema.Number;
|
|
9
|
+
credential: Schema.Struct<{
|
|
10
|
+
aaguid: typeof Schema.String;
|
|
11
|
+
backedUp: typeof Schema.Boolean;
|
|
12
|
+
counter: typeof Schema.Number;
|
|
13
|
+
deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
|
|
14
|
+
id: typeof Schema.String;
|
|
15
|
+
transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
|
|
16
|
+
userId: typeof Schema.String;
|
|
17
|
+
}>;
|
|
18
|
+
enabled: typeof Schema.Boolean;
|
|
19
|
+
id: typeof Schema.String;
|
|
20
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
21
|
+
platform: Schema.optional<Schema.Struct<{
|
|
22
|
+
icon: Schema.optional<typeof Schema.String>;
|
|
23
|
+
name: Schema.optional<typeof Schema.String>;
|
|
24
|
+
}>>;
|
|
25
|
+
updatedAt: typeof Schema.Number;
|
|
26
|
+
userId: Schema.optional<typeof Schema.String>;
|
|
27
|
+
}>;
|
|
28
|
+
export type Passkey = typeof Passkey.Type;
|
|
29
|
+
export declare const isPasskey: (payload: unknown) => payload is Passkey;
|
|
30
|
+
export declare const PasskeySummary: Schema.TaggedStruct<"PasskeySummary", {
|
|
31
|
+
id: typeof Schema.String;
|
|
32
|
+
userId: typeof Schema.String;
|
|
33
|
+
credential: Schema.Struct<{
|
|
34
|
+
aaguid: typeof Schema.String;
|
|
35
|
+
}>;
|
|
36
|
+
enabled: typeof Schema.Boolean;
|
|
37
|
+
createdAt: typeof Schema.Number;
|
|
38
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
39
|
+
}>;
|
|
40
|
+
export type PasskeySummary = typeof PasskeySummary.Type;
|
|
41
|
+
export declare const isPasskeySummary: (payload: unknown) => payload is PasskeySummary;
|
|
42
|
+
export declare const FindAllPasskeys: Schema.TaggedStruct<"FindAllPasskeys", {
|
|
43
|
+
cursor: Schema.NullOr<typeof Schema.String>;
|
|
44
|
+
records: Schema.Array$<Schema.TaggedStruct<"PasskeySummary", {
|
|
45
|
+
id: typeof Schema.String;
|
|
46
|
+
userId: typeof Schema.String;
|
|
47
|
+
credential: Schema.Struct<{
|
|
48
|
+
aaguid: typeof Schema.String;
|
|
49
|
+
}>;
|
|
50
|
+
enabled: typeof Schema.Boolean;
|
|
51
|
+
createdAt: typeof Schema.Number;
|
|
52
|
+
lastUsed: Schema.optional<typeof Schema.Number>;
|
|
53
|
+
}>>;
|
|
54
|
+
}>;
|
|
55
|
+
export type FindAllPasskeys = typeof FindAllPasskeys.Type;
|
|
56
|
+
export declare const DeletedPasskey: Schema.TaggedStruct<"DeletedPasskey", {
|
|
57
|
+
passkeyId: typeof Schema.String;
|
|
58
|
+
credentialId: typeof Schema.String;
|
|
59
|
+
rpId: typeof Schema.String;
|
|
60
|
+
}>;
|
|
61
|
+
export type DeletedPasskey = typeof DeletedPasskey.Type;
|
|
62
|
+
export declare const isDeletedPasskey: (payload: unknown) => payload is DeletedPasskey;
|
|
63
|
+
//# 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;AAI/B,eAAO,MAAM,sBAAsB,0DAAyD,CAAA;AAI5F,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;;;;;;;;;EASzB,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;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AAEzD,eAAO,MAAM,cAAc;;;;EAIzB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,cAC3B,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/* Registration Options */
|
|
3
|
+
export const UserVerificationSchema = Schema.Literal("required", "preferred", "discouraged");
|
|
4
|
+
/* Passkey */
|
|
5
|
+
export const CredentialDeviceType = ["singleDevice", "multiDevice"];
|
|
6
|
+
export const Transports = [
|
|
7
|
+
"ble",
|
|
8
|
+
"hybrid",
|
|
9
|
+
"internal",
|
|
10
|
+
"nfc",
|
|
11
|
+
"usb",
|
|
12
|
+
"cable",
|
|
13
|
+
"smart-card",
|
|
14
|
+
];
|
|
15
|
+
/* Passkey */
|
|
16
|
+
export const Passkey = Schema.TaggedStruct("Passkey", {
|
|
17
|
+
createdAt: Schema.Number,
|
|
18
|
+
credential: Schema.Struct({
|
|
19
|
+
aaguid: Schema.String,
|
|
20
|
+
backedUp: Schema.Boolean,
|
|
21
|
+
counter: Schema.Number,
|
|
22
|
+
deviceType: Schema.Literal(...CredentialDeviceType),
|
|
23
|
+
id: Schema.String, // webAuthnId (Base64Url)
|
|
24
|
+
transports: Schema.Array(Schema.Literal(...Transports)),
|
|
25
|
+
userId: Schema.String, // webAuthnUserId (Base64Url)
|
|
26
|
+
}),
|
|
27
|
+
enabled: Schema.Boolean,
|
|
28
|
+
id: Schema.String,
|
|
29
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
30
|
+
platform: Schema.optional(Schema.Struct({
|
|
31
|
+
icon: Schema.optional(Schema.String),
|
|
32
|
+
name: Schema.optional(Schema.String),
|
|
33
|
+
})),
|
|
34
|
+
updatedAt: Schema.Number,
|
|
35
|
+
userId: Schema.optional(Schema.String),
|
|
36
|
+
});
|
|
37
|
+
export const isPasskey = (payload) => Schema.is(Passkey)(payload);
|
|
38
|
+
export const PasskeySummary = Schema.TaggedStruct("PasskeySummary", {
|
|
39
|
+
id: Schema.String,
|
|
40
|
+
userId: Schema.String,
|
|
41
|
+
credential: Schema.Struct({
|
|
42
|
+
aaguid: Schema.String,
|
|
43
|
+
}),
|
|
44
|
+
enabled: Schema.Boolean,
|
|
45
|
+
createdAt: Schema.Number,
|
|
46
|
+
lastUsed: Schema.optional(Schema.Number),
|
|
47
|
+
});
|
|
48
|
+
export const isPasskeySummary = (payload) => Schema.is(PasskeySummary)(payload);
|
|
49
|
+
export const FindAllPasskeys = Schema.TaggedStruct("FindAllPasskeys", {
|
|
50
|
+
cursor: Schema.NullOr(Schema.String),
|
|
51
|
+
records: Schema.Array(PasskeySummary),
|
|
52
|
+
});
|
|
53
|
+
export const DeletedPasskey = Schema.TaggedStruct("DeletedPasskey", {
|
|
54
|
+
passkeyId: Schema.String,
|
|
55
|
+
credentialId: Schema.String,
|
|
56
|
+
rpId: Schema.String,
|
|
57
|
+
});
|
|
58
|
+
export const isDeletedPasskey = (payload) => Schema.is(DeletedPasskey)(payload);
|
|
59
|
+
//# 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,0BAA0B;AAE1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;AAE5F,aAAa;AAEb,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAA;AAG5E,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK;IACL,QAAQ;IACR,UAAU;IACV,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;CACJ,CAAA;AAGV,aAAa;AAEb,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE;IACpD,SAAS,EAAE,MAA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QACxB,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,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;AAIF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;IAClE,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAA6B,EAAE,CAC9E,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\n/* Registration Options */\n\nexport const UserVerificationSchema = Schema.Literal(\"required\", \"preferred\", \"discouraged\")\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 id: Schema.String,\n userId: Schema.String,\n credential: Schema.Struct({\n aaguid: 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 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\nexport type FindAllPasskeys = typeof FindAllPasskeys.Type\n\nexport const DeletedPasskey = Schema.TaggedStruct(\"DeletedPasskey\", {\n passkeyId: Schema.String,\n credentialId: Schema.String,\n rpId: Schema.String,\n})\n\nexport type DeletedPasskey = typeof DeletedPasskey.Type\n\nexport const isDeletedPasskey = (payload: unknown): payload is DeletedPasskey =>\n Schema.is(DeletedPasskey)(payload)\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
|
+
userVerified: typeof Schema.Boolean;
|
|
10
|
+
verified: typeof Schema.Boolean;
|
|
11
|
+
}>>;
|
|
12
|
+
userId: typeof Schema.String;
|
|
13
|
+
}>;
|
|
14
|
+
export type Principal = typeof Principal.Type;
|
|
15
|
+
export declare const isPrincipal: (payload: unknown) => payload is Principal;
|
|
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 isExtendedPrincipal: (payload: unknown) => payload is ExtendedPrincipal;
|
|
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;;;;;;;;;;;EAapB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAE7C,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,SAA0C,CAAA;AAEpG,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAkB5B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAE7D,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,iBAC3B,CAAA;AAEvC,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,46 @@
|
|
|
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
|
+
userVerified: Schema.Boolean,
|
|
11
|
+
verified: Schema.Boolean,
|
|
12
|
+
})),
|
|
13
|
+
userId: Schema.String,
|
|
14
|
+
});
|
|
15
|
+
export const isPrincipal = (payload) => Schema.is(Principal)(payload);
|
|
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 isExtendedPrincipal = (payload) => Schema.is(ExtendedPrincipal)(payload);
|
|
34
|
+
export const IdToken = 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(IdToken)(payload);
|
|
46
|
+
//# sourceMappingURL=principal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal.js","sourceRo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,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,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAgC,EAAE,CACpF,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;AAEvC,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 userVerified: Schema.Boolean,\n verified: Schema.Boolean,\n })\n ),\n userId: Schema.String,\n})\n\nexport type Principal = typeof Principal.Type\n\nexport const isPrincipal = (payload: unknown): payload is Principal => Schema.is(Principal)(payload)\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 isExtendedPrincipal = (payload: unknown): payload is ExtendedPrincipal =>\n Schema.is(ExtendedPrincipal)(payload)\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,32 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
1
|
+
import { NotFound } from "./schemas/errors.js";
|
|
2
|
+
export interface TenancyOptions {
|
|
3
3
|
tenancyId: string;
|
|
4
4
|
/**
|
|
5
5
|
* @default https://api.passlock.dev
|
|
6
6
|
*/
|
|
7
7
|
endpoint?: string;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface AuthenticatedTenancyOptions extends TenancyOptions {
|
|
10
10
|
apiKey: string;
|
|
11
11
|
}
|
|
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
12
|
export declare class UnexpectedError extends Error {
|
|
31
13
|
readonly _tag: string;
|
|
32
14
|
constructor(data: {
|
|
@@ -35,5 +17,5 @@ export declare class UnexpectedError extends Error {
|
|
|
35
17
|
});
|
|
36
18
|
readonly toString: () => string;
|
|
37
19
|
}
|
|
38
|
-
export
|
|
20
|
+
export declare const isNotFound: (payload: unknown) => payload is NotFound;
|
|
39
21
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,2BAA4B,SAAQ,cAAc;IACjE,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;AAED,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,QAAwC,CAAA"}
|
package/dist/shared.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
|
|
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
|
-
}
|
|
2
|
+
import { NotFound } from "./schemas/errors.js";
|
|
13
3
|
export class UnexpectedError extends Error {
|
|
14
4
|
_tag;
|
|
15
5
|
constructor(data) {
|
|
@@ -18,4 +8,5 @@ export class UnexpectedError extends Error {
|
|
|
18
8
|
}
|
|
19
9
|
toString = () => `${this.message} (_tag: ${this._tag})`;
|
|
20
10
|
}
|
|
11
|
+
export const isNotFound = (payload) => Schema.is(NotFound)(payload);
|
|
21
12
|
//# sourceMappingURL=shared.js.map
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAc9C,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;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\nimport { NotFound } from \"./schemas/errors.js\"\n\nexport interface TenancyOptions {\n tenancyId: string\n /**\n * @default https://api.passlock.dev\n */\n endpoint?: string\n}\n\nexport interface AuthenticatedTenancyOptions extends TenancyOptions {\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\nexport const isNotFound = (payload: unknown): payload is NotFound => Schema.is(NotFound)(payload)\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,OAAO,EAAoB,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC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AC,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"]}
|