@passlock/node 2.0.2 → 2.0.4
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/effect.d.ts +2 -2
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +1 -1
- package/dist/effect.js.map +1 -1
- package/dist/errors.d.ts +21 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +16 -11
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +39 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- 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 +33 -17
- package/dist/passkey/passkey.d.ts.map +1 -1
- package/dist/passkey/passkey.js +113 -66
- package/dist/passkey/passkey.js.map +1 -1
- package/dist/principal/principal.d.ts +7 -7
- package/dist/principal/principal.d.ts.map +1 -1
- package/dist/principal/principal.js +23 -22
- package/dist/principal/principal.js.map +1 -1
- package/dist/safe.d.ts +39 -21
- package/dist/safe.d.ts.map +1 -1
- package/dist/safe.js +30 -13
- package/dist/safe.js.map +1 -1
- package/dist/schemas/errors.d.ts +1 -24
- package/dist/schemas/errors.d.ts.map +1 -1
- package/dist/schemas/errors.js +28 -40
- package/dist/schemas/errors.js.map +1 -1
- package/dist/schemas/passkey.d.ts +33 -9
- package/dist/schemas/passkey.d.ts.map +1 -1
- package/dist/schemas/passkey.js +8 -9
- package/dist/schemas/passkey.js.map +1 -1
- package/package.json +6 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAErD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,Q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G;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,OAAO,KACf,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA0C,CAAA;AAwD5E;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,GAAG,GAAG,EACjB,QAAQ,aAAa,EACrB,UAAU,OAAO,EACjB,UAAU,mBAAmB,KAC5B,MAAM,CAAC,MAAM,CACd,eAAe,EACf,mBAAmB,GAAG,mBAAmB,EACzC,YAAY,CAsCV,CAAA"}
|
package/dist/network.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Effect service tag for the fetch implementation.
|
|
4
|
+
*
|
|
5
|
+
* Supply this service with `Effect.provide` / layers to swap fetch behavior
|
|
6
|
+
* in tests or alternate runtimes.
|
|
7
|
+
*/
|
|
8
|
+
export class NetworkFetch extends Context.Tag("@passlock/node/network/Fetch")() {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Default live fetch layer backed by `globalThis.fetch`.
|
|
12
|
+
*/
|
|
13
|
+
export const NetworkFetchLive = Layer.succeed(NetworkFetch, globalThis.fetch);
|
|
14
|
+
/**
|
|
15
|
+
* Raised when the underlying fetch call fails before a response is received.
|
|
16
|
+
*/
|
|
17
|
+
export class NetworkRequestError extends Data.TaggedError("@error/NetworkRequest") {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Raised when request payload serialization fails.
|
|
21
|
+
*/
|
|
22
|
+
export class NetworkPayloadError extends Data.TaggedError("@error/NetworkPayload") {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Raised when response body parsing fails.
|
|
26
|
+
*/
|
|
27
|
+
export class NetworkResponseError extends Data.TaggedError("@error/NetworkResponse") {
|
|
28
|
+
}
|
|
29
|
+
const formatMessage = (cause, fallback) => cause instanceof Error ? cause.message : fallback;
|
|
30
|
+
/**
|
|
31
|
+
* Convert an HTTP status code into its status family bucket.
|
|
32
|
+
*
|
|
33
|
+
* Returns `undefined` for codes outside the 2xx-5xx families.
|
|
34
|
+
*/
|
|
35
|
+
export const statusToCase = (status) => {
|
|
36
|
+
if (status >= 200 && status <= 299)
|
|
37
|
+
return "2xx";
|
|
38
|
+
if (status >= 300 && status <= 399)
|
|
39
|
+
return "3xx";
|
|
40
|
+
if (status >= 400 && status <= 499)
|
|
41
|
+
return "4xx";
|
|
42
|
+
if (status >= 500 && status <= 599)
|
|
43
|
+
return "5xx";
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
|
46
|
+
const resolveStatusHandler = (response, cases) => {
|
|
47
|
+
const statusCase = statusToCase(response.status);
|
|
48
|
+
if (!statusCase)
|
|
49
|
+
return cases.orElse;
|
|
50
|
+
const handler = cases[statusCase];
|
|
51
|
+
return (handler ?? cases.orElse);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Route a {@link NetworkResponse} to the first matching status-family handler.
|
|
55
|
+
*
|
|
56
|
+
* Invariants:
|
|
57
|
+
* - `2xx`/`3xx`/`4xx`/`5xx` handlers are matched by status family.
|
|
58
|
+
* - `orElse` is always used as a fallback when no specific family handler exists.
|
|
59
|
+
* - The returned effect type is inferred as the union of all handler effects.
|
|
60
|
+
*/
|
|
61
|
+
export const matchStatus = (response, cases) => Effect.suspend(() => {
|
|
62
|
+
const handler = resolveStatusHandler(response, cases);
|
|
63
|
+
return handler(response);
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Serialize an optional payload into a JSON request body.
|
|
67
|
+
*
|
|
68
|
+
* Invariants:
|
|
69
|
+
* - `GET` requests cannot carry a payload and fail with `NetworkPayloadError`.
|
|
70
|
+
* - when a payload exists, `content-type: application/json` is emitted.
|
|
71
|
+
*/
|
|
72
|
+
const serializePayload = (method, payload) => {
|
|
73
|
+
if (payload === undefined) {
|
|
74
|
+
return Effect.succeed(undefined);
|
|
75
|
+
}
|
|
76
|
+
if (method === "get") {
|
|
77
|
+
return Effect.fail(new NetworkPayloadError({
|
|
78
|
+
method,
|
|
79
|
+
message: "GET requests do not support a request body",
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
return Effect.try({
|
|
83
|
+
try: () => ({
|
|
84
|
+
body: JSON.stringify(payload),
|
|
85
|
+
headers: { "content-type": "application/json" },
|
|
86
|
+
}),
|
|
87
|
+
catch: (cause) => new NetworkPayloadError({
|
|
88
|
+
method,
|
|
89
|
+
message: formatMessage(cause, "Unable to serialize payload to JSON"),
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Convert `Headers` into a readonly plain record.
|
|
95
|
+
*/
|
|
96
|
+
export const headersToRecord = (headers) => Object.fromEntries(headers.entries());
|
|
97
|
+
const normalizeHeaders = (headers) => {
|
|
98
|
+
if (headers instanceof Headers) {
|
|
99
|
+
return new Headers(headers);
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(headers)) {
|
|
102
|
+
return new Headers(headers);
|
|
103
|
+
}
|
|
104
|
+
return new Headers(headers);
|
|
105
|
+
};
|
|
106
|
+
const mergeHeaders = (...headers) => Object.assign({}, ...headers);
|
|
107
|
+
/**
|
|
108
|
+
* Build a lazy, memoized JSON parser effect from a response.
|
|
109
|
+
*
|
|
110
|
+
* Invariants:
|
|
111
|
+
* - parsing happens on effect execution, not during response construction.
|
|
112
|
+
* - parsing uses `response.clone()` so the original response body remains untouched.
|
|
113
|
+
*/
|
|
114
|
+
const makeJsonEffect = (response, context) => {
|
|
115
|
+
let cached;
|
|
116
|
+
return Effect.tryPromise({
|
|
117
|
+
try: () => {
|
|
118
|
+
cached = cached ?? response.clone().json();
|
|
119
|
+
return cached;
|
|
120
|
+
},
|
|
121
|
+
catch: (cause) => new NetworkResponseError({
|
|
122
|
+
method: context.method,
|
|
123
|
+
url: context.url,
|
|
124
|
+
message: formatMessage(cause, "Unable to parse response JSON"),
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const toNetworkResponse = (response, context) => ({
|
|
129
|
+
status: response.status,
|
|
130
|
+
statusText: response.statusText,
|
|
131
|
+
statusMessage: response.statusText,
|
|
132
|
+
headers: headersToRecord(response.headers),
|
|
133
|
+
json: makeJsonEffect(response, context),
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Execute a fetch request using the injected {@link NetworkFetch} service.
|
|
137
|
+
*
|
|
138
|
+
* Invariants:
|
|
139
|
+
* - method is always normalized to upper-case before dispatch.
|
|
140
|
+
* - JSON payload (if present) is serialized before request execution.
|
|
141
|
+
* - caller headers override payload-derived headers when keys overlap.
|
|
142
|
+
* - the returned `NetworkResponse.json` remains lazy.
|
|
143
|
+
*/
|
|
144
|
+
export const fetchNetwork = (url, method, payload, options) => Effect.gen(function* () {
|
|
145
|
+
const requestUrl = String(url);
|
|
146
|
+
const context = { method, url: requestUrl };
|
|
147
|
+
const fetchImpl = yield* NetworkFetch;
|
|
148
|
+
const serialized = yield* serializePayload(method, payload);
|
|
149
|
+
const providedHeaders = options?.headers
|
|
150
|
+
? headersToRecord(normalizeHeaders(options.headers))
|
|
151
|
+
: {};
|
|
152
|
+
const requestHeaders = mergeHeaders(serialized?.headers ?? {}, providedHeaders);
|
|
153
|
+
const hasHeaders = Object.keys(requestHeaders).length > 0;
|
|
154
|
+
const response = yield* Effect.tryPromise({
|
|
155
|
+
try: () => fetchImpl(requestUrl, {
|
|
156
|
+
method: method.toUpperCase(),
|
|
157
|
+
...(hasHeaders ? { headers: requestHeaders } : {}),
|
|
158
|
+
...(serialized
|
|
159
|
+
? {
|
|
160
|
+
body: serialized.body,
|
|
161
|
+
}
|
|
162
|
+
: {}),
|
|
163
|
+
}),
|
|
164
|
+
catch: (cause) => new NetworkRequestError({
|
|
165
|
+
method,
|
|
166
|
+
url: requestUrl,
|
|
167
|
+
message: formatMessage(cause, "Network request failed"),
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
return toNetworkResponse(response, context);
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAsCrD;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,EAG1E;CAAG;AAEN;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA8B,KAAK,CAAC,OAAO,CACtE,YAAY,EACZ,UAAU,CAAC,KAAK,CACjB,CAAA;AAwED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CACvD,uBAAuB,CAKvB;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CACvD,uBAAuB,CAIvB;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CACxD,wBAAwB,CAKxB;CAAG;AAEL,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAU,EAAE,CACjE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAA;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAAc,EACyB,EAAE;IACzC,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,KAAK,CAAA;IAChD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,KAAK,CAAA;IAChD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,KAAK,CAAA;IAChD,IAAI,MAAM,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AAM,CAAC,UAAU,CAAC;QACxC,GAAG,EAAE,GAAG,EAAE,CACR,SAAS,CAAC,UAAU,EAAE;YACpB,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;YAC5B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClD,GAAG,CAAC,UAAU;gBACZ,CAAC,CAAC;oBACE,IAAI,EAAE,UAAU,CAAC,IAAI;iBACtB;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACJ,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,mBAAmB,CAAC;YACtB,MAAM;YACN,GAAG,EAAE,UAAU;YACf,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,wBAAwB,CAAC;SACxD,CAAC;KACL,CAAC,CAAA;IAEF,OAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAC,CAAA","sourcesContent":["import { Context, Data, Effect, Layer } from \"effect\"\n\n/**\n * Supported HTTP methods accepted by {@link fetchNetwork}.\n */\nexport type NetworkMethod = \"get\" | \"post\" | \"delete\" | \"patch\"\n\n/**\n * Lightweight response model used by this package.\n *\n * Invariants:\n * - `json` is lazy: parsing only happens when the effect is run.\n * - `json` is memoized per response wrapper, so repeated evaluation does not\n * parse the same payload multiple times.\n */\nexport interface NetworkResponse {\n readonly status: number\n readonly statusText: string\n readonly statusMessage: string\n readonly headers: Readonly<Record<string, string>>\n readonly json: Effect.Effect<unknown, NetworkResponseError>\n}\n\n/**\n * Accepted request header input formats.\n */\nexport type NetworkHeaders =\n | Headers\n | Readonly<Record<string, string>>\n | Array<[string, string]>\n\n/**\n * Optional request options for {@link fetchNetwork}.\n */\nexport interface FetchNetworkOptions {\n readonly headers?: NetworkHeaders\n}\n\n/**\n * Effect service tag for the fetch implementation.\n *\n * Supply this service with `Effect.provide` / layers to swap fetch behavior\n * in tests or alternate runtimes.\n */\nexport class NetworkFetch extends Context.Tag(\"@passlock/node/network/Fetch\")<\n NetworkFetch,\n typeof fetch\n>() {}\n\n/**\n * Default live fetch layer backed by `globalThis.fetch`.\n */\nexport const NetworkFetchLive: Layer.Layer<NetworkFetch> = Layer.succeed(\n NetworkFetch,\n globalThis.fetch\n)\n\n/**\n * HTTP status buckets used by {@link matchStatus}.\n */\nexport type NetworkResponseStatusCase = \"2xx\" | \"3xx\" | \"4xx\" | \"5xx\"\n\ntype MatchStatusHandler<\n Resp extends NetworkResponse = NetworkResponse,\n A = unknown,\n E = unknown,\n> = (response: Resp) => Effect.Effect<A, E, never>\n\ntype HandlerEffect<\n Cases extends MatchStatusCases<Resp>,\n Resp extends NetworkResponse,\n Case extends NetworkResponseStatusCase | \"orElse\",\n> = Case extends keyof Cases\n ? NonNullable<Cases[Case]> extends MatchStatusHandler<Resp>\n ? ReturnType<NonNullable<Cases[Case]>>\n : never\n : never\n\ntype MatchStatusEffectUnion<\n Cases extends MatchStatusCases<Resp>,\n Resp extends NetworkResponse,\n> =\n | HandlerEffect<Cases, Resp, \"2xx\">\n | HandlerEffect<Cases, Resp, \"3xx\">\n | HandlerEffect<Cases, Resp, \"4xx\">\n | HandlerEffect<Cases, Resp, \"5xx\">\n | HandlerEffect<Cases, Resp, \"orElse\">\n\ntype MatchStatusResolvedHandler<\n Cases extends MatchStatusCases<Resp>,\n Resp extends NetworkResponse,\n> = NonNullable<\n Cases[\"2xx\"] | Cases[\"3xx\"] | Cases[\"4xx\"] | Cases[\"5xx\"] | Cases[\"orElse\"]\n>\n\ntype EffectSuccess<T> =\n T extends Effect.Effect<infer A, unknown, unknown> ? A : never\n\ntype EffectError<T> =\n T extends Effect.Effect<unknown, infer E, unknown> ? E : never\n\ntype EffectContext<T> =\n T extends Effect.Effect<unknown, unknown, infer R> ? R : never\n\n/**\n * Handlers used by {@link matchStatus}.\n *\n * Invariants:\n * - `orElse` is always required.\n * - Specific status family handlers are optional and fall back to `orElse`\n * when missing.\n */\nexport interface MatchStatusCases<\n Resp extends NetworkResponse = NetworkResponse,\n> {\n readonly \"2xx\"?: MatchStatusHandler<Resp>\n readonly \"3xx\"?: MatchStatusHandler<Resp>\n readonly \"4xx\"?: MatchStatusHandler<Resp>\n readonly \"5xx\"?: MatchStatusHandler<Resp>\n readonly orElse: MatchStatusHandler<Resp>\n}\n\ntype RequestContext = {\n readonly method: NetworkMethod\n readonly url: string\n}\n\n/**\n * Raised when the underlying fetch call fails before a response is received.\n */\nexport class NetworkRequestError extends Data.TaggedError(\n \"@error/NetworkRequest\"\n)<{\n readonly method: NetworkMethod\n readonly url: string\n readonly message: string\n}> {}\n\n/**\n * Raised when request payload serialization fails.\n */\nexport class NetworkPayloadError extends Data.TaggedError(\n \"@error/NetworkPayload\"\n)<{\n readonly method: NetworkMethod\n readonly message: string\n}> {}\n\n/**\n * Raised when response body parsing fails.\n */\nexport class NetworkResponseError extends Data.TaggedError(\n \"@error/NetworkResponse\"\n)<{\n readonly method: NetworkMethod\n readonly url: string\n readonly message: string\n}> {}\n\nconst formatMessage = (cause: unknown, fallback: string): string =>\n cause instanceof Error ? cause.message : fallback\n\n/**\n * Convert an HTTP status code into its status family bucket.\n *\n * Returns `undefined` for codes outside the 2xx-5xx families.\n */\nexport const statusToCase = (\n status: number\n): NetworkResponseStatusCase | undefined => {\n if (status >= 200 && status <= 299) return \"2xx\"\n if (status >= 300 && status <= 399) return \"3xx\"\n if (status >= 400 && status <= 499) return \"4xx\"\n if (status >= 500 && status <= 599) return \"5xx\"\n\n return undefined\n}\n\nconst resolveStatusHandler = <\n Resp extends NetworkResponse,\n Cases extends MatchStatusCases<Resp>,\n>(\n response: Resp,\n cases: Cases\n): MatchStatusResolvedHandler<Cases, Resp> => {\n const statusCase = statusToCase(response.status)\n if (!statusCase)\n return cases.orElse as MatchStatusResolvedHandler<Cases, Resp>\n\n const handler = cases[statusCase]\n return (handler ?? cases.orElse) as MatchStatusResolvedHandler<Cases, Resp>\n}\n\n/**\n * Route a {@link NetworkResponse} to the first matching status-family handler.\n *\n * Invariants:\n * - `2xx`/`3xx`/`4xx`/`5xx` handlers are matched by status family.\n * - `orElse` is always used as a fallback when no specific family handler exists.\n * - The returned effect type is inferred as the union of all handler effects.\n */\nexport const matchStatus = <\n Resp extends NetworkResponse,\n Cases extends MatchStatusCases<Resp>,\n>(\n response: Resp,\n cases: Cases\n): Effect.Effect<\n EffectSuccess<MatchStatusEffectUnion<Cases, Resp>>,\n EffectError<MatchStatusEffectUnion<Cases, Resp>>,\n EffectContext<MatchStatusEffectUnion<Cases, Resp>>\n> =>\n Effect.suspend(() => {\n const handler = resolveStatusHandler(response, cases)\n return handler(response)\n }) as Effect.Effect<\n EffectSuccess<MatchStatusEffectUnion<Cases, Resp>>,\n EffectError<MatchStatusEffectUnion<Cases, Resp>>,\n EffectContext<MatchStatusEffectUnion<Cases, Resp>>\n >\n\n/**\n * Serialize an optional payload into a JSON request body.\n *\n * Invariants:\n * - `GET` requests cannot carry a payload and fail with `NetworkPayloadError`.\n * - when a payload exists, `content-type: application/json` is emitted.\n */\nconst serializePayload = (\n method: NetworkMethod,\n payload?: unknown\n): Effect.Effect<\n | {\n readonly body: string\n readonly headers: Readonly<Record<string, string>>\n }\n | undefined,\n NetworkPayloadError\n> => {\n if (payload === undefined) {\n return Effect.succeed(undefined)\n }\n\n if (method === \"get\") {\n return Effect.fail(\n new NetworkPayloadError({\n method,\n message: \"GET requests do not support a request body\",\n })\n )\n }\n\n return Effect.try({\n try: () => ({\n body: JSON.stringify(payload),\n headers: { \"content-type\": \"application/json\" },\n }),\n catch: (cause) =>\n new NetworkPayloadError({\n method,\n message: formatMessage(cause, \"Unable to serialize payload to JSON\"),\n }),\n })\n}\n\n/**\n * Convert `Headers` into a readonly plain record.\n */\nexport const headersToRecord = (\n headers: Headers\n): Readonly<Record<string, string>> => Object.fromEntries(headers.entries())\n\nconst normalizeHeaders = (headers: NetworkHeaders): Headers => {\n if (headers instanceof Headers) {\n return new Headers(headers)\n }\n\n if (Array.isArray(headers)) {\n return new Headers(headers)\n }\n\n return new Headers(headers)\n}\n\nconst mergeHeaders = (\n ...headers: ReadonlyArray<Readonly<Record<string, string>>>\n): Readonly<Record<string, string>> => Object.assign({}, ...headers)\n\n/**\n * Build a lazy, memoized JSON parser effect from a response.\n *\n * Invariants:\n * - parsing happens on effect execution, not during response construction.\n * - parsing uses `response.clone()` so the original response body remains untouched.\n */\nconst makeJsonEffect = (\n response: Response,\n context: RequestContext\n): Effect.Effect<unknown, NetworkResponseError> => {\n let cached: Promise<unknown> | undefined\n\n return Effect.tryPromise({\n try: () => {\n cached = cached ?? response.clone().json()\n return cached\n },\n catch: (cause) =>\n new NetworkResponseError({\n method: context.method,\n url: context.url,\n message: formatMessage(cause, \"Unable to parse response JSON\"),\n }),\n })\n}\n\nconst toNetworkResponse = (\n response: Response,\n context: RequestContext\n): NetworkResponse => ({\n status: response.status,\n statusText: response.statusText,\n statusMessage: response.statusText,\n headers: headersToRecord(response.headers),\n json: makeJsonEffect(response, context),\n})\n\n/**\n * Execute a fetch request using the injected {@link NetworkFetch} service.\n *\n * Invariants:\n * - method is always normalized to upper-case before dispatch.\n * - JSON payload (if present) is serialized before request execution.\n * - caller headers override payload-derived headers when keys overlap.\n * - the returned `NetworkResponse.json` remains lazy.\n */\nexport const fetchNetwork = (\n url: string | URL,\n method: NetworkMethod,\n payload?: unknown,\n options?: FetchNetworkOptions\n): Effect.Effect<\n NetworkResponse,\n NetworkRequestError | NetworkPayloadError,\n NetworkFetch\n> =>\n Effect.gen(function* () {\n const requestUrl = String(url)\n const context: RequestContext = { method, url: requestUrl }\n const fetchImpl = yield* NetworkFetch\n const serialized = yield* serializePayload(method, payload)\n\n const providedHeaders = options?.headers\n ? headersToRecord(normalizeHeaders(options.headers))\n : {}\n\n const requestHeaders = mergeHeaders(\n serialized?.headers ?? {},\n providedHeaders\n )\n const hasHeaders = Object.keys(requestHeaders).length > 0\n\n const response = yield* Effect.tryPromise({\n try: () =>\n fetchImpl(requestUrl, {\n method: method.toUpperCase(),\n ...(hasHeaders ? { headers: requestHeaders } : {}),\n ...(serialized\n ? {\n body: serialized.body,\n }\n : {}),\n }),\n catch: (cause) =>\n new NetworkRequestError({\n method,\n url: requestUrl,\n message: formatMessage(cause, \"Network request failed\"),\n }),\n })\n\n return toNetworkResponse(response, context)\n })\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from "@effect/platform";
|
|
2
1
|
import { Effect, type Layer, Stream } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { type NetworkFetch } from "../network.js";
|
|
3
|
+
import { ForbiddenError, NotFoundError } from "../schemas/index.js";
|
|
4
|
+
import * as PasskeySchemas from "../schemas/passkey.js";
|
|
5
5
|
import type { AuthenticatedOptions } from "../shared.js";
|
|
6
6
|
/**
|
|
7
7
|
* WebAuthn specific passkey data
|
|
@@ -13,9 +13,10 @@ export type Credential = {
|
|
|
13
13
|
aaguid: string;
|
|
14
14
|
backedUp: boolean;
|
|
15
15
|
counter: number;
|
|
16
|
-
deviceType: CredentialDeviceType;
|
|
17
|
-
transports: ReadonlyArray<Transports>;
|
|
16
|
+
deviceType: PasskeySchemas.CredentialDeviceType;
|
|
17
|
+
transports: ReadonlyArray<PasskeySchemas.Transports>;
|
|
18
18
|
publicKey: Uint8Array<ArrayBufferLike>;
|
|
19
|
+
rpId: string;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Passkeys are usually synced across devices **but only within
|
|
@@ -71,26 +72,35 @@ export type PasskeySummary = {
|
|
|
71
72
|
readonly createdAt: number;
|
|
72
73
|
};
|
|
73
74
|
export declare const isPasskeySummary: (payload: unknown) => payload is PasskeySummary;
|
|
75
|
+
export type UpdatedPasskeys = {
|
|
76
|
+
_tag: "UpdatedPasskeys";
|
|
77
|
+
updated: ReadonlyArray<Passkey>;
|
|
78
|
+
};
|
|
79
|
+
export declare const isUpdatedPasskeys: (payload: unknown) => payload is UpdatedPasskeys;
|
|
74
80
|
export type FindAllPasskeys = {
|
|
75
81
|
readonly _tag: "FindAllPasskeys";
|
|
76
82
|
readonly cursor: string | null;
|
|
77
83
|
readonly records: ReadonlyArray<PasskeySummary>;
|
|
78
84
|
};
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
export declare const isFindAllPasskeys: (payload: unknown) => payload is FindAllPasskeys;
|
|
86
|
+
export type UpdatedPasskeyUsernames = {
|
|
87
|
+
_tag: "UpdatedPasskeyUsernames";
|
|
88
|
+
credentials: ReadonlyArray<{
|
|
89
|
+
rpId: string;
|
|
90
|
+
userId: string;
|
|
91
|
+
username: string;
|
|
92
|
+
displayName: string;
|
|
93
|
+
}>;
|
|
84
94
|
};
|
|
85
|
-
export declare const
|
|
95
|
+
export declare const isUpdatedPasskeyUsernames: (payload: unknown) => payload is UpdatedPasskeyUsernames;
|
|
86
96
|
export interface GetPasskeyOptions extends AuthenticatedOptions {
|
|
87
97
|
passkeyId: string;
|
|
88
98
|
}
|
|
89
|
-
export declare const getPasskey: (options: GetPasskeyOptions,
|
|
99
|
+
export declare const getPasskey: (options: GetPasskeyOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<Passkey, NotFoundError | ForbiddenError>;
|
|
90
100
|
export interface DeletePasskeyOptions extends AuthenticatedOptions {
|
|
91
101
|
passkeyId: string;
|
|
92
102
|
}
|
|
93
|
-
export declare const deletePasskey: (options: DeletePasskeyOptions,
|
|
103
|
+
export declare const deletePasskey: (options: DeletePasskeyOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<Passkey, NotFoundError | ForbiddenError>;
|
|
94
104
|
/**
|
|
95
105
|
* @category Passkeys
|
|
96
106
|
*/
|
|
@@ -101,16 +111,22 @@ export interface AssignUserOptions extends AuthenticatedOptions {
|
|
|
101
111
|
*/
|
|
102
112
|
userId: string;
|
|
103
113
|
}
|
|
104
|
-
export declare const assignUser: (options: AssignUserOptions,
|
|
114
|
+
export declare const assignUser: (options: AssignUserOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<Passkey, NotFoundError | ForbiddenError>;
|
|
105
115
|
export interface UpdatePasskeyOptions extends AuthenticatedOptions {
|
|
106
116
|
passkeyId: string;
|
|
107
117
|
userId?: string;
|
|
108
118
|
username?: string;
|
|
109
119
|
}
|
|
110
|
-
export declare const updatePasskey: (options: UpdatePasskeyOptions,
|
|
111
|
-
export
|
|
120
|
+
export declare const updatePasskey: (options: UpdatePasskeyOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<Passkey, NotFoundError | ForbiddenError>;
|
|
121
|
+
export interface UpdatePasskeyUsernamesOptions extends AuthenticatedOptions {
|
|
122
|
+
userId: string;
|
|
123
|
+
username: string;
|
|
124
|
+
displayName?: string;
|
|
125
|
+
}
|
|
126
|
+
export declare const updatePasskeyUsernames: (options: UpdatePasskeyUsernamesOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<UpdatedPasskeyUsernames, NotFoundError | ForbiddenError>;
|
|
127
|
+
export declare const listPasskeysStream: (options: AuthenticatedOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Stream.Stream<PasskeySummary, ForbiddenError>;
|
|
112
128
|
export interface ListPasskeyOptions extends AuthenticatedOptions {
|
|
113
129
|
cursor?: string;
|
|
114
130
|
}
|
|
115
|
-
export declare const listPasskeys: (options: ListPasskeyOptions,
|
|
131
|
+
export declare const listPasskeys: (options: ListPasskeyOptions, fetchLayer?: Layer.Layer<NetworkFetch>) => Effect.Effect<FindAllPasskeys, ForbiddenError>;
|
|
116
132
|
//# sourceMappingURL=passkey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/passkey/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/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AAoB,EAC7B,aAAY,KAAK,CAAC,KAAK,CAAC,YAAY,CAAoB,KACvD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CA4CrD,CAAA;AA6DH,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,sBAAsB,GACjC,SAAS,6BAA6B,EACtC,aAAY,KAAK,CAAC,KAAK,CAAC,YAAY,CAAoB,KACvD,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,aAAa,GAAG,cAAc,CAkBrE,CAAA;AAIH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,oBAAoB,EAC7B,aAAY,KAAK,CAAC,KAAK,CAAC,YAAY,CAAoB,KACvD,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAW5C,CAAA;AAEH,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,YAAY,GACvB,SAAS,kBAAkB,EAC3B,aAAY,KAAK,CAAC,KAAK,CAAC,YAAY,CAAoB,KACvD,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,cAAc,CAqC7C,CAAA"}
|
package/dist/passkey/passkey.js
CHANGED
|
@@ -1,111 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FindAllPasskeysSchema,
|
|
4
|
-
import
|
|
5
|
-
export const isPasskey = (payload) => Schema.is(
|
|
6
|
-
export const isPasskeySummary = (payload) => Schema.is(
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
|
|
1
|
+
import { Array, Chunk, Effect, Match, Option, pipe, Schema, Stream, } from "effect";
|
|
2
|
+
import { fetchNetwork, matchStatus, NetworkFetchLive, } from "../network.js";
|
|
3
|
+
import { FindAllPasskeys as FindAllPasskeysSchema, ForbiddenError, NotFoundError, } from "../schemas/index.js";
|
|
4
|
+
import * as PasskeySchemas from "../schemas/passkey.js";
|
|
5
|
+
export const isPasskey = (payload) => Schema.is(PasskeySchemas.Passkey)(payload);
|
|
6
|
+
export const isPasskeySummary = (payload) => Schema.is(PasskeySchemas.PasskeySummary)(payload);
|
|
7
|
+
export const isUpdatedPasskeys = (payload) => Schema.is(PasskeySchemas.UpdatedPasskeys)(payload);
|
|
8
|
+
export const isFindAllPasskeys = (payload) => Schema.is(PasskeySchemas.FindAllPasskeys)(payload);
|
|
9
|
+
export const isUpdatedPasskeyUsernames = (payload) => {
|
|
10
|
+
if (typeof payload !== "object")
|
|
11
|
+
return false;
|
|
12
|
+
if (payload === null)
|
|
13
|
+
return false;
|
|
14
|
+
if (!("_tag" in payload))
|
|
15
|
+
return false;
|
|
16
|
+
if (typeof payload._tag !== "string")
|
|
17
|
+
return false;
|
|
18
|
+
if (payload._tag !== "UpdatedPasskeyUsernames")
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
};
|
|
22
|
+
/* END UpdatedPasskeyUsernames */
|
|
23
|
+
const authorizationHeaders = (apiKey) => ({
|
|
24
|
+
authorization: `Bearer ${apiKey}`,
|
|
25
|
+
});
|
|
26
|
+
const decodeResponseJson = (response, schema) => pipe(response.json, Effect.flatMap(Schema.decodeUnknown(schema)));
|
|
27
|
+
export const getPasskey = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
10
28
|
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
11
29
|
const { tenancyId, passkeyId } = options;
|
|
12
30
|
const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
|
|
13
|
-
const response = yield*
|
|
14
|
-
headers:
|
|
15
|
-
})
|
|
16
|
-
const encoded = yield*
|
|
17
|
-
"2xx": () =>
|
|
18
|
-
orElse: () =>
|
|
31
|
+
const response = yield* fetchNetwork(url, "get", undefined, {
|
|
32
|
+
headers: authorizationHeaders(options.apiKey),
|
|
33
|
+
});
|
|
34
|
+
const encoded = yield* matchStatus(response, {
|
|
35
|
+
"2xx": (res) => decodeResponseJson(res, PasskeySchemas.Passkey),
|
|
36
|
+
orElse: (res) => decodeResponseJson(res, Schema.Union(ForbiddenError, NotFoundError)),
|
|
19
37
|
});
|
|
20
38
|
return yield* pipe(Match.value(encoded), Match.tag("Passkey", (data) => Effect.succeed(data)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.exhaustive);
|
|
21
39
|
}), Effect.catchTags({
|
|
40
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
41
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
42
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
22
43
|
ParseError: (err) => Effect.die(err),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}), Effect.provide(httpClient));
|
|
26
|
-
export const deletePasskey = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
|
|
27
|
-
const client = yield* HttpClient.HttpClient;
|
|
44
|
+
}), Effect.provide(fetchLayer));
|
|
45
|
+
export const deletePasskey = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
28
46
|
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
29
47
|
const { tenancyId, passkeyId } = options;
|
|
30
48
|
const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
|
|
31
|
-
const response = yield*
|
|
32
|
-
headers:
|
|
33
|
-
})
|
|
34
|
-
const encoded = yield*
|
|
35
|
-
"2xx": () =>
|
|
36
|
-
orElse: () =>
|
|
49
|
+
const response = yield* fetchNetwork(url, "delete", undefined, {
|
|
50
|
+
headers: authorizationHeaders(options.apiKey),
|
|
51
|
+
});
|
|
52
|
+
const encoded = yield* matchStatus(response, {
|
|
53
|
+
"2xx": (res) => decodeResponseJson(res, PasskeySchemas.Passkey),
|
|
54
|
+
orElse: (res) => decodeResponseJson(res, Schema.Union(ForbiddenError, NotFoundError)),
|
|
37
55
|
});
|
|
38
|
-
return yield* pipe(Match.value(encoded), Match.tag("
|
|
56
|
+
return yield* pipe(Match.value(encoded), Match.tag("Passkey", (deletedPasskey) => Effect.succeed(deletedPasskey)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.exhaustive);
|
|
39
57
|
}), Effect.catchTags({
|
|
58
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
59
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
60
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
40
61
|
ParseError: (err) => Effect.die(err),
|
|
41
|
-
|
|
42
|
-
ResponseError: (err) => Effect.die(err),
|
|
43
|
-
}), Effect.provide(httpClient));
|
|
62
|
+
}), Effect.provide(fetchLayer));
|
|
44
63
|
// TODO reuse updatePasskey
|
|
45
|
-
export const assignUser = (options,
|
|
46
|
-
const client = yield* HttpClient.HttpClient;
|
|
64
|
+
export const assignUser = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
47
65
|
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
48
66
|
const { userId, passkeyId } = options;
|
|
49
67
|
const { tenancyId } = options;
|
|
50
68
|
const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
|
|
51
|
-
const response = yield*
|
|
52
|
-
headers:
|
|
53
|
-
})
|
|
54
|
-
const encoded = yield*
|
|
55
|
-
"2xx": () =>
|
|
56
|
-
orElse: () =>
|
|
69
|
+
const response = yield* fetchNetwork(url, "patch", { userId }, {
|
|
70
|
+
headers: authorizationHeaders(options.apiKey),
|
|
71
|
+
});
|
|
72
|
+
const encoded = yield* matchStatus(response, {
|
|
73
|
+
"2xx": (res) => decodeResponseJson(res, PasskeySchemas.Passkey),
|
|
74
|
+
orElse: (res) => decodeResponseJson(res, Schema.Union(NotFoundError, ForbiddenError)),
|
|
57
75
|
});
|
|
58
76
|
return yield* pipe(Match.value(encoded), Match.tag("Passkey", (passkey) => Effect.succeed(passkey)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
59
77
|
}), Effect.catchTags({
|
|
60
|
-
|
|
78
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
79
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
80
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
61
81
|
ParseError: (err) => Effect.die(err),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}), Effect.provide(httpClient));
|
|
65
|
-
export const updatePasskey = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
|
|
66
|
-
const client = yield* HttpClient.HttpClient;
|
|
82
|
+
}), Effect.provide(fetchLayer));
|
|
83
|
+
export const updatePasskey = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
67
84
|
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
68
85
|
const { userId, passkeyId, username } = options;
|
|
69
86
|
const { tenancyId } = options;
|
|
70
87
|
const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
|
|
71
|
-
const response = yield*
|
|
72
|
-
headers:
|
|
73
|
-
})
|
|
74
|
-
const encoded = yield*
|
|
75
|
-
"2xx": () =>
|
|
76
|
-
orElse: () =>
|
|
88
|
+
const response = yield* fetchNetwork(url, "patch", { userId, username }, {
|
|
89
|
+
headers: authorizationHeaders(options.apiKey),
|
|
90
|
+
});
|
|
91
|
+
const encoded = yield* matchStatus(response, {
|
|
92
|
+
"2xx": (res) => decodeResponseJson(res, PasskeySchemas.Passkey),
|
|
93
|
+
orElse: (res) => decodeResponseJson(res, Schema.Union(NotFoundError, ForbiddenError)),
|
|
77
94
|
});
|
|
78
95
|
return yield* pipe(Match.value(encoded), Match.tag("Passkey", (passkey) => Effect.succeed(passkey)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
79
96
|
}), Effect.catchTags({
|
|
80
|
-
|
|
97
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
98
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
99
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
81
100
|
ParseError: (err) => Effect.die(err),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
}), Effect.provide(fetchLayer));
|
|
102
|
+
const updateUserPasskeys = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
103
|
+
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
104
|
+
const { userId, username } = options;
|
|
105
|
+
const { tenancyId } = options;
|
|
106
|
+
const url = new URL(`/${tenancyId}/users/${userId}/passkeys/`, baseUrl);
|
|
107
|
+
const response = yield* fetchNetwork(url, "patch", { userId, username }, {
|
|
108
|
+
headers: authorizationHeaders(options.apiKey),
|
|
109
|
+
});
|
|
110
|
+
const encoded = yield* matchStatus(response, {
|
|
111
|
+
"2xx": (res) => decodeResponseJson(res, PasskeySchemas.UpdatedPasskeys),
|
|
112
|
+
orElse: (res) => decodeResponseJson(res, Schema.Union(NotFoundError, ForbiddenError)),
|
|
113
|
+
});
|
|
114
|
+
return yield* pipe(Match.value(encoded), Match.tag("UpdatedPasskeys", (result) => Effect.succeed(result)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
115
|
+
}), Effect.catchTags({
|
|
116
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
117
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
118
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
119
|
+
ParseError: (err) => Effect.die(err),
|
|
120
|
+
}), Effect.provide(fetchLayer));
|
|
121
|
+
export const updatePasskeyUsernames = (options, fetchLayer = NetworkFetchLive) => pipe(updateUserPasskeys(options, fetchLayer), Effect.map((result) => result.updated), Effect.map(Array.map((passkey) => {
|
|
122
|
+
return {
|
|
123
|
+
rpId: passkey.credential.rpId,
|
|
124
|
+
userId: passkey.credential.userId,
|
|
125
|
+
username: passkey.credential.username,
|
|
126
|
+
displayName: options.displayName ?? passkey.credential.username,
|
|
127
|
+
};
|
|
128
|
+
})), Effect.map((credentials) => ({
|
|
129
|
+
_tag: "UpdatedPasskeyUsernames",
|
|
130
|
+
credentials,
|
|
131
|
+
})));
|
|
85
132
|
/* List Passkeys */
|
|
86
|
-
export const listPasskeysStream = (options,
|
|
133
|
+
export const listPasskeysStream = (options, fetchLayer = NetworkFetchLive) => pipe(Stream.paginateChunkEffect(null, (cursor) => pipe(listPasskeys(cursor ? { ...options, cursor } : options, fetchLayer), Effect.map((result) => [
|
|
87
134
|
Chunk.fromIterable(result.records),
|
|
88
135
|
Option.fromNullable(result.cursor),
|
|
89
136
|
]))));
|
|
90
|
-
export const listPasskeys = (options,
|
|
91
|
-
const client = yield* HttpClient.HttpClient;
|
|
137
|
+
export const listPasskeys = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
|
|
92
138
|
const baseUrl = options.endpoint ?? "https://api.passlock.dev";
|
|
93
139
|
const { tenancyId } = options;
|
|
94
140
|
const url = new URL(`/${tenancyId}/passkeys/`, baseUrl);
|
|
95
141
|
if (options.cursor) {
|
|
96
142
|
url.searchParams.append("cursor", options.cursor);
|
|
97
143
|
}
|
|
98
|
-
const response = yield*
|
|
99
|
-
headers:
|
|
100
|
-
})
|
|
101
|
-
const encoded = yield*
|
|
102
|
-
"2xx": () =>
|
|
103
|
-
orElse: () =>
|
|
144
|
+
const response = yield* fetchNetwork(url, "get", undefined, {
|
|
145
|
+
headers: authorizationHeaders(options.apiKey),
|
|
146
|
+
});
|
|
147
|
+
const encoded = yield* matchStatus(response, {
|
|
148
|
+
"2xx": (res) => decodeResponseJson(res, FindAllPasskeysSchema),
|
|
149
|
+
orElse: (res) => decodeResponseJson(res, ForbiddenError),
|
|
104
150
|
});
|
|
105
151
|
return yield* pipe(Match.value(encoded), Match.tag("FindAllPasskeys", (data) => Effect.succeed(data)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
|
|
106
152
|
}), Effect.catchTags({
|
|
153
|
+
"@error/NetworkPayload": (err) => Effect.die(err),
|
|
154
|
+
"@error/NetworkRequest": (err) => Effect.die(err),
|
|
155
|
+
"@error/NetworkResponse": (err) => Effect.die(err),
|
|
107
156
|
ParseError: (err) => Effect.die(err),
|
|
108
|
-
|
|
109
|
-
ResponseError: (err) => Effect.die(err),
|
|
110
|
-
}), Effect.provide(httpClient));
|
|
157
|
+
}), Effect.provide(fetchLayer));
|
|
111
158
|
//# sourceMappingURL=passkey.js.map
|