@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passlock/node",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "Passkey authentication for NodeJS backends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"passkey",
|
|
@@ -29,15 +29,10 @@
|
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
30
|
"default": "./dist/index.js"
|
|
31
31
|
},
|
|
32
|
-
"./
|
|
33
|
-
"types": "./dist/
|
|
34
|
-
"import": "./dist/
|
|
35
|
-
"default": "./dist/
|
|
36
|
-
},
|
|
37
|
-
"./user": {
|
|
38
|
-
"types": "./dist/user/index.d.ts",
|
|
39
|
-
"import": "./dist/user/index.js",
|
|
40
|
-
"default": "./dist/user/index.js"
|
|
32
|
+
"./effects": {
|
|
33
|
+
"types": "./dist/effects/index.d.ts",
|
|
34
|
+
"import": "./dist/effects/index.js",
|
|
35
|
+
"default": "./dist/effects/index.js"
|
|
41
36
|
}
|
|
42
37
|
},
|
|
43
38
|
"module": "./dist/index.js",
|
|
@@ -48,24 +43,24 @@
|
|
|
48
43
|
"!dist/**/*.spec.*"
|
|
49
44
|
],
|
|
50
45
|
"dependencies": {
|
|
51
|
-
"@effect/platform": "^0.
|
|
52
|
-
"@effect/platform-node": "^0.
|
|
53
|
-
"effect": "3.19.10",
|
|
46
|
+
"@effect/platform": "^0.94.1",
|
|
47
|
+
"@effect/platform-node": "^0.104.0",
|
|
54
48
|
"jose": "^6.1.3"
|
|
55
49
|
},
|
|
56
50
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@types/node": "
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"prettier": "^3.7.4",
|
|
64
|
-
"publint": "0.3.15",
|
|
51
|
+
"@biomejs/biome": "^2.3.11",
|
|
52
|
+
"@effect/vitest": "^0.27.0",
|
|
53
|
+
"@types/node": "25.0.9",
|
|
54
|
+
"globals": "^17.0.0",
|
|
55
|
+
"npm-check-updates": "^19.3.1",
|
|
56
|
+
"publint": "0.3.17",
|
|
65
57
|
"rimraf": "^6.1.2",
|
|
66
58
|
"tsx": "4.21.0",
|
|
67
59
|
"typescript": "^5.9.3",
|
|
68
|
-
"
|
|
60
|
+
"vitest": "^3.2.4"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"effect": "3.19.14"
|
|
69
64
|
},
|
|
70
65
|
"engines": {
|
|
71
66
|
"node": ">=22"
|
|
@@ -77,14 +72,18 @@
|
|
|
77
72
|
"build:readme": "LATEST=${npm_package_version} tsx ../../scripts/replace-readme-tokens.ts ./packages/node",
|
|
78
73
|
"clean": "tsc --build --clean",
|
|
79
74
|
"clean:full": "rimraf dist tsconfig.tsbuildinfo",
|
|
80
|
-
"format": "prettier --write \"src/**/*.+(js|ts|json)\"",
|
|
81
|
-
"lint": "prettier --check \"src/**/*.+(js|ts|json)\" && eslint ./src",
|
|
82
|
-
"lint:fix": "prettier --check \"src/**/*.+(js|ts|json)\" && eslint ./src --fix",
|
|
83
75
|
"replaceTokens": "LATEST=${npm_package_version} tsx ../../scripts/replace-tokens.ts ./packages/node",
|
|
84
|
-
"test": "vitest
|
|
76
|
+
"test": "vitest --project unit",
|
|
77
|
+
"test:it": "vitest --project integration",
|
|
78
|
+
"test:all": "vitest run --project unit --project integration",
|
|
85
79
|
"test:coverage": "vitest run --coverage",
|
|
86
80
|
"test:ui": "vitest --coverage.enabled=true --ui",
|
|
87
81
|
"test:watch": "vitest dev",
|
|
88
|
-
"typecheck": "tsc --noEmit"
|
|
82
|
+
"typecheck": "tsc --noEmit",
|
|
83
|
+
"lint": "biome check .",
|
|
84
|
+
"lint:fix": "biome check --fix .",
|
|
85
|
+
"lint:ci": "biome ci .",
|
|
86
|
+
"format": "biome format --fix .",
|
|
87
|
+
"format:check": "biome format ."
|
|
89
88
|
}
|
|
90
89
|
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "@effect/platform";
|
|
2
|
-
import type { RequestError, ResponseError } from "@effect/platform/HttpClientError";
|
|
3
|
-
import { Effect, Schema } from "effect";
|
|
4
|
-
import type { ParseError } from "effect/ParseResult";
|
|
5
|
-
import { Forbidden, type ApiOptions, type AuthorizedApiOptions } from "../shared.js";
|
|
6
|
-
declare const InvalidCode_base: Schema.TaggedErrorClass<InvalidCode, "@error/InvalidCode", {
|
|
7
|
-
readonly _tag: Schema.tag<"@error/InvalidCode">;
|
|
8
|
-
} & {
|
|
9
|
-
message: typeof Schema.String;
|
|
10
|
-
}>;
|
|
11
|
-
export declare class InvalidCode extends InvalidCode_base {
|
|
12
|
-
static isInvalidCode: (payload: unknown) => payload is InvalidCode;
|
|
13
|
-
}
|
|
14
|
-
export declare const Principal: Schema.TaggedStruct<"Principal", {
|
|
15
|
-
tenancyId: typeof Schema.String;
|
|
16
|
-
userId: typeof Schema.String;
|
|
17
|
-
code: typeof Schema.String;
|
|
18
|
-
authenticatorId: typeof Schema.String;
|
|
19
|
-
passkey: Schema.optionalWith<Schema.Struct<{
|
|
20
|
-
userVerified: Schema.optionalWith<typeof Schema.Boolean, {
|
|
21
|
-
nullable: true;
|
|
22
|
-
}>;
|
|
23
|
-
}>, {
|
|
24
|
-
nullable: true;
|
|
25
|
-
}>;
|
|
26
|
-
createdAt: typeof Schema.DateFromNumber;
|
|
27
|
-
expiresAt: typeof Schema.DateFromNumber;
|
|
28
|
-
}>;
|
|
29
|
-
export type Principal = typeof Principal.Type;
|
|
30
|
-
export declare const isPrincipal: (payload: unknown) => payload is Principal;
|
|
31
|
-
export declare const IdToken: Schema.TaggedStruct<"IdToken", {
|
|
32
|
-
"a:id": typeof Schema.String;
|
|
33
|
-
"a:typ": typeof Schema.String;
|
|
34
|
-
iss: Schema.Literal<["passlock.dev"]>;
|
|
35
|
-
"pk:uv": typeof Schema.Boolean;
|
|
36
|
-
sub: typeof Schema.String;
|
|
37
|
-
jti: typeof Schema.String;
|
|
38
|
-
aud: typeof Schema.String;
|
|
39
|
-
iat: typeof Schema.Number;
|
|
40
|
-
exp: typeof Schema.Number;
|
|
41
|
-
}>;
|
|
42
|
-
export type IdToken = typeof IdToken.Type;
|
|
43
|
-
export declare const exchangeCode: (code: string, options: AuthorizedApiOptions) => Effect.Effect<Principal, InvalidCode | Forbidden | ParseError | RequestError | ResponseError, HttpClient.HttpClient>;
|
|
44
|
-
declare const VerificationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
45
|
-
readonly _tag: "VerificationError";
|
|
46
|
-
} & Readonly<A>;
|
|
47
|
-
export declare class VerificationError extends VerificationError_base<{
|
|
48
|
-
message: string;
|
|
49
|
-
}> {
|
|
50
|
-
}
|
|
51
|
-
export declare const verifyIdToken: (token: string, options: ApiOptions) => Effect.Effect<Principal, VerificationError | ParseError>;
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -1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AAG,UAAU,CAsCtD,CAAC"}
|
package/dist/principal/effect.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { HttpClient, HttpClientResponse } from "@effect/platform";
|
|
2
|
-
import { Data, Effect, Match, pipe, Schema } from "effect";
|
|
3
|
-
import * as jose from "jose";
|
|
4
|
-
import { Forbidden, } from "../shared.js";
|
|
5
|
-
export class InvalidCode extends Schema.TaggedError("@error/InvalidCode")("@error/InvalidCode", { message: Schema.String }) {
|
|
6
|
-
static isInvalidCode = (payload) => Schema.is(InvalidCode)(payload);
|
|
7
|
-
}
|
|
8
|
-
export const Principal = Schema.TaggedStruct("Principal", {
|
|
9
|
-
tenancyId: Schema.String,
|
|
10
|
-
userId: Schema.String,
|
|
11
|
-
code: Schema.String,
|
|
12
|
-
authenticatorId: Schema.String,
|
|
13
|
-
passkey: Schema.optionalWith(Schema.Struct({
|
|
14
|
-
userVerified: Schema.optionalWith(Schema.Boolean, { nullable: true }),
|
|
15
|
-
}), {
|
|
16
|
-
nullable: true,
|
|
17
|
-
}),
|
|
18
|
-
createdAt: Schema.DateFromNumber,
|
|
19
|
-
expiresAt: Schema.DateFromNumber,
|
|
20
|
-
});
|
|
21
|
-
export const isPrincipal = (payload) => Schema.is(Principal)(payload);
|
|
22
|
-
export const IdToken = Schema.TaggedStruct("IdToken", {
|
|
23
|
-
"a:id": Schema.String,
|
|
24
|
-
"a:typ": Schema.String,
|
|
25
|
-
iss: Schema.Literal("passlock.dev"),
|
|
26
|
-
"pk:uv": Schema.Boolean,
|
|
27
|
-
sub: Schema.String,
|
|
28
|
-
jti: Schema.String,
|
|
29
|
-
aud: Schema.String,
|
|
30
|
-
iat: Schema.Number,
|
|
31
|
-
exp: Schema.Number,
|
|
32
|
-
});
|
|
33
|
-
export const exchangeCode = (code, options) => Effect.gen(function* () {
|
|
34
|
-
const client = yield* HttpClient.HttpClient;
|
|
35
|
-
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
36
|
-
const url = new URL(`/${options.tenancyId}/principal/${code}`, baseUrl);
|
|
37
|
-
const response = yield* pipe(client.get(url, {
|
|
38
|
-
headers: { Authorization: `Bearer ${options.apiKey}` },
|
|
39
|
-
}));
|
|
40
|
-
const encoded = yield* HttpClientResponse.matchStatus(response, {
|
|
41
|
-
"2xx": () => HttpClientResponse.schemaBodyJson(Principal)(response),
|
|
42
|
-
orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(InvalidCode, Forbidden))(response),
|
|
43
|
-
});
|
|
44
|
-
return yield* pipe(Match.value(encoded), Match.tag("Principal", (principal) => Effect.succeed(principal)), Match.tag("@error/InvalidCode", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
45
|
-
});
|
|
46
|
-
export class VerificationError extends Data.TaggedError("VerificationError") {
|
|
47
|
-
}
|
|
48
|
-
export const verifyIdToken = (token, options) => Effect.gen(function* () {
|
|
49
|
-
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
50
|
-
const JWKS = jose.createRemoteJWKSet(new URL("/.well-known/jwks.json", baseUrl));
|
|
51
|
-
const { payload } = yield* Effect.tryPromise({
|
|
52
|
-
try: () => jose.jwtVerify(token, JWKS, {
|
|
53
|
-
issuer: "passlock.dev",
|
|
54
|
-
audience: options.tenancyId,
|
|
55
|
-
}),
|
|
56
|
-
catch: (err) => err instanceof Error
|
|
57
|
-
? new VerificationError({ message: err.message })
|
|
58
|
-
: new VerificationError({ message: String(err) }),
|
|
59
|
-
});
|
|
60
|
-
const idToken = yield* Schema.decodeUnknown(IdToken)({
|
|
61
|
-
...payload,
|
|
62
|
-
_tag: "IdToken",
|
|
63
|
-
});
|
|
64
|
-
const principal = {
|
|
65
|
-
_tag: "Principal",
|
|
66
|
-
tenancyId: options.tenancyId,
|
|
67
|
-
userId: idToken.sub,
|
|
68
|
-
code: idToken.jti,
|
|
69
|
-
authenticatorId: idToken["a:id"],
|
|
70
|
-
passkey: {
|
|
71
|
-
userVerified: idToken["pk:uv"],
|
|
72
|
-
},
|
|
73
|
-
createdAt: new Date(idToken.iat * 1000),
|
|
74
|
-
expiresAt: new Date(idToken.exp * 1000),
|
|
75
|
-
};
|
|
76
|
-
return principal;
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=effect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/principal/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKlE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3D,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EACL,SAAS,GAGV,MAAM,cAAc,CAAC;AAEtB,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,CACjD,oBAAoB,CACrB,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACjD,MAAM,CAAC,aAAa,GAAG,CAAC,OAAgB,EAA0B,EAAE,CAClE,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;;AAGpC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;IACxD,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,eAAe,EAAE,MAAM,CAAC,MAAM;IAC9B,OAAO,EAAE,MAAM,CAAC,YAAY,CAC1B,MAAM,CAAC,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KACtE,CAAC,EACF;QACE,QAAQ,EAAE,IAA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AU,CAAC;QAC3C,GAAG,EAAE,GAAG,EAAE,CACR,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;YAC1B,MAAM,EAAE,cAAc;YACtB,QAAQ,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACJ,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,YAAY,KAAK;YAClB,CAAC,CAAC,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;YACjD,CAAC,CAAC,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;KACtD,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,GAAG,OAAO;QACV,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,GAAG;QACnB,IAAI,EAAE,OAAO,CAAC,GAAG;QACjB,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC;QAChC,OAAO,EAAE;YACP,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC;SAC/B;QACD,SAAS,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;QACvC,SAAS,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;KACxC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC,CAAC","sourcesContent":["import { HttpClient, HttpClientResponse } from \"@effect/platform\";\nimport type {\n RequestError,\n ResponseError,\n} from \"@effect/platform/HttpClientError\";\nimport { Data, Effect, Match, pipe, Schema } from \"effect\";\nimport type { ParseError } from \"effect/ParseResult\";\nimport * as jose from \"jose\";\n\nimport {\n Forbidden,\n type ApiOptions,\n type AuthorizedApiOptions,\n} from \"../shared.js\";\n\nexport class InvalidCode extends Schema.TaggedError<InvalidCode>(\n \"@error/InvalidCode\",\n)(\"@error/InvalidCode\", { message: Schema.String }) {\n static isInvalidCode = (payload: unknown): payload is InvalidCode =>\n Schema.is(InvalidCode)(payload);\n}\n\nexport const Principal = Schema.TaggedStruct(\"Principal\", {\n tenancyId: Schema.String,\n userId: Schema.String,\n code: Schema.String,\n authenticatorId: Schema.String,\n passkey: Schema.optionalWith(\n Schema.Struct({\n userVerified: Schema.optionalWith(Schema.Boolean, { nullable: true }),\n }),\n {\n nullable: true,\n },\n ),\n createdAt: Schema.DateFromNumber,\n expiresAt: Schema.DateFromNumber,\n});\n\nexport type Principal = typeof Principal.Type;\n\nexport const isPrincipal = (payload: unknown): payload is Principal =>\n Schema.is(Principal)(payload);\n\nexport const IdToken = Schema.TaggedStruct(\"IdToken\", {\n \"a:id\": Schema.String,\n \"a:typ\": Schema.String,\n iss: Schema.Literal(\"passlock.dev\"),\n \"pk:uv\": Schema.Boolean,\n sub: Schema.String,\n jti: Schema.String,\n aud: Schema.String,\n iat: Schema.Number,\n exp: Schema.Number,\n});\n\nexport type IdToken = typeof IdToken.Type;\n\nexport const exchangeCode = (\n code: string,\n options: AuthorizedApiOptions,\n): Effect.Effect<\n Principal,\n InvalidCode | Forbidden | ParseError | RequestError | ResponseError,\n HttpClient.HttpClient\n> =>\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient;\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\";\n const url = new URL(`/${options.tenancyId}/principal/${code}`, baseUrl);\n\n const response = yield* pipe(\n client.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }),\n );\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(Principal)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(InvalidCode, Forbidden))(\n response,\n ),\n });\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Principal\", (principal) => Effect.succeed(principal)),\n Match.tag(\"@error/InvalidCode\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive,\n );\n });\n\nexport class VerificationError extends Data.TaggedError(\"VerificationError\")<{\n message: string;\n}> {}\n\nexport const verifyIdToken = (\n token: string,\n options: ApiOptions,\n): Effect.Effect<Principal, VerificationError | ParseError> =>\n Effect.gen(function* () {\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\";\n const JWKS = jose.createRemoteJWKSet(\n new URL(\"/.well-known/jwks.json\", baseUrl),\n );\n\n const { payload } = yield* Effect.tryPromise({\n try: () =>\n jose.jwtVerify(token, JWKS, {\n issuer: \"passlock.dev\",\n audience: options.tenancyId,\n }),\n catch: (err) =>\n err instanceof Error\n ? new VerificationError({ message: err.message })\n : new VerificationError({ message: String(err) }),\n });\n\n const idToken = yield* Schema.decodeUnknown(IdToken)({\n ...payload,\n _tag: \"IdToken\",\n });\n\n const principal: Principal = {\n _tag: \"Principal\",\n tenancyId: options.tenancyId,\n userId: idToken.sub,\n code: idToken.jti,\n authenticatorId: idToken[\"a:id\"],\n passkey: {\n userVerified: idToken[\"pk:uv\"],\n },\n createdAt: new Date(idToken.iat * 1000),\n expiresAt: new Date(idToken.exp * 1000),\n };\n\n return principal;\n });\n"]}
|
package/dist/user/effect.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "@effect/platform";
|
|
2
|
-
import type { RequestError, ResponseError } from "@effect/platform/HttpClientError";
|
|
3
|
-
import type { HttpBodyError } from "@effect/platform/HttpBody";
|
|
4
|
-
import { Effect, Schema } from "effect";
|
|
5
|
-
import type { ParseError } from "effect/ParseResult";
|
|
6
|
-
import { Forbidden, NotFound, type AuthorizedApiOptions } from "../shared.js";
|
|
7
|
-
export declare const AssignedUser: Schema.Struct<{
|
|
8
|
-
userId: typeof Schema.String;
|
|
9
|
-
authenticatorId: typeof Schema.String;
|
|
10
|
-
updatedAt: typeof Schema.DateFromNumber;
|
|
11
|
-
}>;
|
|
12
|
-
export type AssignedUser = typeof AssignedUser.Type;
|
|
13
|
-
export interface AssignUserOptions extends AuthorizedApiOptions {
|
|
14
|
-
userId: string;
|
|
15
|
-
authenticatorId: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const assignUser: (options: AssignUserOptions) => Effect.Effect<AssignedUser, NotFound | Forbidden | ParseError | RequestError | HttpBodyError | ResponseError, HttpClient.HttpClient>;
|
|
18
|
-
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/user/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACd,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE9E,eAAO,MAAM,YAAY;;;;EAIvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AASpD,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,KACzB,MAAM,CAAC,MAAM,CACd,YAAY,EACV,QAAQ,GACR,SAAS,GACT,UAAU,GACV,YAAY,GACZ,aAAa,GACb,aAAa,EACf,UAAU,CAAC,UAAU,CAmCnB,CAAC"}
|
package/dist/user/effect.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { HttpClient, HttpClientRequest, HttpClientResponse, } from "@effect/platform";
|
|
2
|
-
import { Effect, Match, pipe, Schema } from "effect";
|
|
3
|
-
import { Forbidden, NotFound } from "../shared.js";
|
|
4
|
-
export const AssignedUser = Schema.Struct({
|
|
5
|
-
userId: Schema.String,
|
|
6
|
-
authenticatorId: Schema.String,
|
|
7
|
-
updatedAt: Schema.DateFromNumber,
|
|
8
|
-
});
|
|
9
|
-
const AssignUserResponse = Schema.Struct({
|
|
10
|
-
_tag: Schema.tag("Success"),
|
|
11
|
-
data: AssignedUser,
|
|
12
|
-
});
|
|
13
|
-
export const assignUser = (options) => Effect.gen(function* () {
|
|
14
|
-
const client = yield* HttpClient.HttpClient;
|
|
15
|
-
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
16
|
-
const { userId, authenticatorId } = options;
|
|
17
|
-
const url = new URL(`/${options.tenancyId}/authenticator/${authenticatorId}`, baseUrl);
|
|
18
|
-
const response = yield* HttpClientRequest.patch(url, {
|
|
19
|
-
headers: { Authorization: `Bearer ${options.apiKey}` },
|
|
20
|
-
}).pipe(HttpClientRequest.bodyJson({ userId }), Effect.flatMap(client.execute));
|
|
21
|
-
const encoded = yield* HttpClientResponse.matchStatus(response, {
|
|
22
|
-
"2xx": () => HttpClientResponse.schemaBodyJson(AssignUserResponse)(response),
|
|
23
|
-
orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(response),
|
|
24
|
-
});
|
|
25
|
-
return yield* pipe(Match.value(encoded), Match.tag("Success", ({ data }) => Effect.succeed(data)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=effect.js.map
|
package/dist/user/effect.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|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CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,EACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAC/B,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,QAAQ,EAAE;QAC9D,KAAK,EAAE,GAAG,EAAE,CACV,kBAAkB,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC;QACjE,MAAM,EAAE,GAAG,EAAE,CACX,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAClE,QAAQ,CACT;KACJ,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,CAAC,IAAI,CAChB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EACpB,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EACxD,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvD,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACxD,KAAK,CAAC,UAAU,CACjB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import {\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from \"@effect/platform\";\n\nimport type {\n RequestError,\n ResponseError,\n} from \"@effect/platform/HttpClientError\";\n\nimport type { HttpBodyError } from \"@effect/platform/HttpBody\";\n\nimport { Effect, Match, pipe, Schema } from \"effect\";\nimport type { ParseError } from \"effect/ParseResult\";\nimport { Forbidden, NotFound, type AuthorizedApiOptions } from \"../shared.js\";\n\nexport const AssignedUser = Schema.Struct({\n userId: Schema.String,\n authenticatorId: Schema.String,\n updatedAt: Schema.DateFromNumber,\n});\n\nexport type AssignedUser = typeof AssignedUser.Type;\n\nconst AssignUserResponse = Schema.Struct({\n _tag: Schema.tag(\"Success\"),\n data: AssignedUser,\n});\n\ntype AssignUserResponse = typeof AssignUserResponse.Type;\n\nexport interface AssignUserOptions extends AuthorizedApiOptions {\n userId: string;\n authenticatorId: string;\n}\n\nexport const assignUser = (\n options: AssignUserOptions,\n): Effect.Effect<\n AssignedUser,\n | NotFound\n | Forbidden\n | ParseError\n | RequestError\n | HttpBodyError\n | ResponseError,\n HttpClient.HttpClient\n> =>\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient;\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\";\n const { userId, authenticatorId } = options;\n\n const url = new URL(\n `/${options.tenancyId}/authenticator/${authenticatorId}`,\n baseUrl,\n );\n\n const response = yield* HttpClientRequest.patch(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(\n HttpClientRequest.bodyJson({ userId }),\n Effect.flatMap(client.execute),\n );\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () =>\n HttpClientResponse.schemaBodyJson(AssignUserResponse)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(\n response,\n ),\n });\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Success\", ({ data }) => Effect.succeed(data)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive,\n );\n });\n"]}
|
package/dist/user/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Forbidden, type NotFound } from "../shared.js";
|
|
2
|
-
import type { AssignedUser, AssignUserOptions } from "./effect.js";
|
|
3
|
-
export { type AssignedUser, type AssignUserOptions as AssignUserRequest, } from "./effect.js";
|
|
4
|
-
/**
|
|
5
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
6
|
-
* @param request
|
|
7
|
-
* @param options
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare const assignUser: (options: AssignUserOptions) => Promise<AssignedUser | NotFound | Forbidden>;
|
|
11
|
-
/**
|
|
12
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
13
|
-
* @param request
|
|
14
|
-
* @param options
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare const assignUserUnsafe: (options: AssignUserOptions) => Promise<AssignedUser>;
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/user/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAmB,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,KACzB,OAAO,CAAC,YAAY,GAAG,QAAQ,GAAG,SAAS,CAkB3C,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,iBAAiB,KACzB,OAAO,CAAC,YAAY,CAiBpB,CAAC"}
|
package/dist/user/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { FetchHttpClient } from "@effect/platform";
|
|
2
|
-
import { Effect, identity, pipe } from "effect";
|
|
3
|
-
import { UnexpectedError } from "../shared.js";
|
|
4
|
-
import { assignUser as assignUserE } from "./effect.js";
|
|
5
|
-
export {} from "./effect.js";
|
|
6
|
-
/**
|
|
7
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
8
|
-
* @param request
|
|
9
|
-
* @param options
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export const assignUser = (options) => pipe(assignUserE(options), Effect.provide(FetchHttpClient.layer), Effect.catchTags({
|
|
13
|
-
HttpBodyError: (err) => Effect.die(new UnexpectedError({
|
|
14
|
-
message: "Invalid request payload",
|
|
15
|
-
_tag: err.reason._tag,
|
|
16
|
-
})),
|
|
17
|
-
ParseError: (err) => Effect.die(new UnexpectedError(err)),
|
|
18
|
-
RequestError: (err) => Effect.die(new UnexpectedError(err)),
|
|
19
|
-
ResponseError: (err) => Effect.die(new UnexpectedError(err)),
|
|
20
|
-
}), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
21
|
-
/**
|
|
22
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
23
|
-
* @param request
|
|
24
|
-
* @param options
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
export const assignUserUnsafe = (options) => pipe(assignUserE(options), Effect.provide(FetchHttpClient.layer), Effect.catchTags({
|
|
28
|
-
HttpBodyError: (err) => Effect.die(new UnexpectedError({
|
|
29
|
-
message: "Invalid request payload",
|
|
30
|
-
_tag: err.reason._tag,
|
|
31
|
-
})),
|
|
32
|
-
ParseError: (err) => Effect.die(new UnexpectedError(err)),
|
|
33
|
-
RequestError: (err) => Effect.die(new UnexpectedError(err)),
|
|
34
|
-
ResponseError: (err) => Effect.die(new UnexpectedError(err)),
|
|
35
|
-
}), Effect.runPromise);
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
package/dist/user/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ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AAG,EAAE,EAAE,CACrB,MAAM,CAAC,GAAG,CACR,IAAI,eAAe,CAAC;QAClB,OAAO,EAAE,yBAAyB;QAClC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI;KACtB,CAAC,CACH;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;IACzD,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;IAC3D,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;CAC7D,CAAC,EACF,MAAM,CAAC,UAAU,CAClB,CAAC","sourcesContent":["import { FetchHttpClient } from \"@effect/platform\";\nimport { Effect, identity, pipe } from \"effect\";\nimport { type Forbidden, type NotFound, UnexpectedError } from \"../shared.js\";\nimport type { AssignedUser, AssignUserOptions } from \"./effect.js\";\nimport { assignUser as assignUserE } from \"./effect.js\";\n\nexport {\n type AssignedUser,\n type AssignUserOptions as AssignUserRequest,\n} from \"./effect.js\";\n\n/**\n * Call the Passlock backend API to assign a userId to an authenticator\n * @param request\n * @param options\n * @returns\n */\nexport const assignUser = (\n options: AssignUserOptions,\n): Promise<AssignedUser | NotFound | Forbidden> =>\n pipe(\n assignUserE(options),\n Effect.provide(FetchHttpClient.layer),\n Effect.catchTags({\n HttpBodyError: (err) =>\n Effect.die(\n new UnexpectedError({\n message: \"Invalid request payload\",\n _tag: err.reason._tag,\n }),\n ),\n ParseError: (err) => Effect.die(new UnexpectedError(err)),\n RequestError: (err) => Effect.die(new UnexpectedError(err)),\n ResponseError: (err) => Effect.die(new UnexpectedError(err)),\n }),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise,\n );\n\n/**\n * Call the Passlock backend API to assign a userId to an authenticator\n * @param request\n * @param options\n * @returns\n */\nexport const assignUserUnsafe = (\n options: AssignUserOptions,\n): Promise<AssignedUser> =>\n pipe(\n assignUserE(options),\n Effect.provide(FetchHttpClient.layer),\n Effect.catchTags({\n HttpBodyError: (err) =>\n Effect.die(\n new UnexpectedError({\n message: \"Invalid request payload\",\n _tag: err.reason._tag,\n }),\n ),\n ParseError: (err) => Effect.die(new UnexpectedError(err)),\n RequestError: (err) => Effect.die(new UnexpectedError(err)),\n ResponseError: (err) => Effect.die(new UnexpectedError(err)),\n }),\n Effect.runPromise,\n );\n"]}
|