@passlock/client 0.9.23 → 0.9.25

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.
Files changed (114) hide show
  1. package/README.md +15 -10
  2. package/README.template.md +130 -0
  3. package/dist/authentication/authenticate.d.ts +2 -2
  4. package/dist/authentication/authenticate.fixture.d.ts +1 -1
  5. package/dist/authentication/authenticate.fixture.js +2 -2
  6. package/dist/authentication/authenticate.fixture.js.map +1 -1
  7. package/dist/authentication/authenticate.js +1 -1
  8. package/dist/authentication/authenticate.js.map +1 -1
  9. package/dist/capabilities/capabilities.d.ts +1 -1
  10. package/dist/capabilities/capabilities.js +1 -1
  11. package/dist/capabilities/capabilities.js.map +1 -1
  12. package/dist/connection/connection.fixture.d.ts +1 -1
  13. package/dist/connection/connection.fixture.js +1 -1
  14. package/dist/connection/connection.fixture.js.map +1 -1
  15. package/dist/connection/connection.js.map +1 -1
  16. package/dist/effect.d.ts +3 -3
  17. package/dist/effect.js +6 -6
  18. package/dist/effect.js.map +1 -1
  19. package/dist/email/email.d.ts +5 -2
  20. package/dist/email/email.fixture.d.ts +1 -1
  21. package/dist/email/email.fixture.js +2 -2
  22. package/dist/email/email.fixture.js.map +1 -1
  23. package/dist/email/email.js +1 -1
  24. package/dist/email/email.js.map +1 -1
  25. package/dist/event/event.d.ts +1 -1
  26. package/dist/event/event.js +1 -1
  27. package/dist/event/event.js.map +1 -1
  28. package/dist/index.js +3 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/logging/eventLogger.js +1 -1
  31. package/dist/logging/eventLogger.js.map +1 -1
  32. package/dist/registration/register.d.ts +2 -2
  33. package/dist/registration/register.fixture.d.ts +1 -1
  34. package/dist/registration/register.fixture.js +2 -2
  35. package/dist/registration/register.fixture.js.map +1 -1
  36. package/dist/registration/register.js +2 -2
  37. package/dist/registration/register.js.map +1 -1
  38. package/dist/rpc/authentication.d.ts +1 -1
  39. package/dist/rpc/authentication.js +1 -1
  40. package/dist/rpc/authentication.js.map +1 -1
  41. package/dist/rpc/client.d.ts +1 -1
  42. package/dist/rpc/client.js +3 -4
  43. package/dist/rpc/client.js.map +1 -1
  44. package/dist/rpc/connection.d.ts +1 -1
  45. package/dist/rpc/connection.js +1 -1
  46. package/dist/rpc/connection.js.map +1 -1
  47. package/dist/rpc/registration.d.ts +1 -1
  48. package/dist/rpc/registration.js +1 -1
  49. package/dist/rpc/registration.js.map +1 -1
  50. package/dist/rpc/social.d.ts +1 -1
  51. package/dist/rpc/social.js +1 -1
  52. package/dist/rpc/social.js.map +1 -1
  53. package/dist/rpc/user.d.ts +1 -1
  54. package/dist/rpc/user.js +1 -1
  55. package/dist/rpc/user.js.map +1 -1
  56. package/dist/social/social.d.ts +2 -2
  57. package/dist/social/social.fixture.d.ts +1 -1
  58. package/dist/social/social.fixture.js +2 -2
  59. package/dist/social/social.fixture.js.map +1 -1
  60. package/dist/social/social.js +2 -2
  61. package/dist/social/social.js.map +1 -1
  62. package/dist/storage/storage.d.ts +1 -1
  63. package/dist/storage/storage.fixture.js.map +1 -1
  64. package/dist/storage/storage.js +4 -0
  65. package/dist/storage/storage.js.map +1 -1
  66. package/dist/test/fixtures.d.ts +1 -1
  67. package/dist/test/fixtures.js +2 -2
  68. package/dist/test/fixtures.js.map +1 -1
  69. package/dist/user/user.d.ts +1 -1
  70. package/dist/user/user.fixture.d.ts +1 -1
  71. package/dist/user/user.fixture.js +2 -2
  72. package/dist/user/user.fixture.js.map +1 -1
  73. package/dist/user/user.js +4 -1
  74. package/dist/user/user.js.map +1 -1
  75. package/dist/version.d.ts +1 -1
  76. package/dist/version.js +1 -1
  77. package/package.json +21 -17
  78. package/src/authentication/authenticate.fixture.ts +4 -2
  79. package/src/authentication/authenticate.test.ts +2 -1
  80. package/src/authentication/authenticate.ts +3 -1
  81. package/src/capabilities/capabilities.ts +2 -1
  82. package/src/connection/connection.fixture.ts +3 -1
  83. package/src/connection/connection.test.ts +2 -1
  84. package/src/connection/connection.ts +1 -0
  85. package/src/effect.ts +12 -18
  86. package/src/email/email.fixture.ts +4 -2
  87. package/src/email/email.test.ts +2 -1
  88. package/src/email/email.ts +3 -1
  89. package/src/event/event.node.test.ts +1 -0
  90. package/src/event/event.test.ts +1 -0
  91. package/src/event/event.ts +2 -1
  92. package/src/index.ts +39 -33
  93. package/src/logging/eventLogger.test.ts +1 -0
  94. package/src/logging/eventLogger.ts +1 -1
  95. package/src/registration/register.fixture.ts +4 -2
  96. package/src/registration/register.test.ts +4 -2
  97. package/src/registration/register.ts +4 -5
  98. package/src/rpc/authentication.ts +14 -2
  99. package/src/rpc/client.ts +5 -4
  100. package/src/rpc/connection.ts +8 -2
  101. package/src/rpc/registration.ts +12 -2
  102. package/src/rpc/social.ts +11 -2
  103. package/src/rpc/user.ts +16 -1
  104. package/src/social/social.fixture.ts +4 -2
  105. package/src/social/social.test.ts +4 -2
  106. package/src/social/social.ts +4 -2
  107. package/src/storage/storage.fixture.ts +1 -0
  108. package/src/storage/storage.test.ts +1 -0
  109. package/src/storage/storage.ts +4 -3
  110. package/src/test/fixtures.ts +4 -2
  111. package/src/user/user.fixture.ts +4 -2
  112. package/src/user/user.test.ts +2 -1
  113. package/src/user/user.ts +3 -1
  114. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAErF,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAW3C,aAAa;AAEb,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAMlE;CAAG;AAMN,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAc,EAA+C,EAAE;IAC5F,OAAO,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AAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PASSLOCK_CLIENT_VERSION = "0.9.23";
1
+ export declare const PASSLOCK_CLIENT_VERSION = "0.9.25";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const PASSLOCK_CLIENT_VERSION = '0.9.23';
1
+ export const PASSLOCK_CLIENT_VERSION = '0.9.25';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passlock/client",
3
- "version": "0.9.23",
3
+ "version": "0.9.25",
4
4
  "description": "Passkey authentication and social login for web apps (Typescript). Framework agnostic",
5
5
  "keywords": [
6
6
  "passkey",
@@ -24,10 +24,11 @@
24
24
  "homepage": "https://passlock.dev",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/passlock-dev/ts-clients.git"
27
+ "url": "git+https://github.com/passlock-dev/passlock.git",
28
+ "directory": "packages/client"
28
29
  },
29
30
  "bugs": {
30
- "url": "https://github.com/passlock-dev/ts-clients/issues",
31
+ "url": "https://github.com/passlock-dev/passlock/issues",
31
32
  "email": "team@passlock.dev"
32
33
  },
33
34
  "type": "module",
@@ -44,30 +45,32 @@
44
45
  "!dist/**/*.spec.*"
45
46
  ],
46
47
  "dependencies": {
47
- "@effect/schema": "0.70.4",
48
+ "@effect/schema": "0.71.0",
48
49
  "@github/webauthn-json": "^2.1.1",
49
- "effect": "3.6.3",
50
- "@passlock/shared": "0.9.23"
50
+ "effect": "3.6.4",
51
+ "@passlock/shared": "0.9.25"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@qetza/replacetokens": "^1.7.0",
54
55
  "@total-typescript/tsconfig": "^1.0.4",
55
56
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
56
57
  "@tsconfig/node20": "^20.1.4",
57
- "@types/node": "^22.2.0",
58
- "@typescript-eslint/eslint-plugin": "^8.0.1",
59
- "@typescript-eslint/parser": "^8.0.1",
58
+ "@types/node": "^22.4.0",
59
+ "@typescript-eslint/eslint-plugin": "^8.1.0",
60
+ "@typescript-eslint/parser": "^8.1.0",
60
61
  "@vitest/coverage-v8": "^2.0.5",
61
62
  "@vitest/ui": "^2.0.5",
62
63
  "eslint": "^9.9.0",
63
64
  "eslint-config-prettier": "^9.1.0",
65
+ "globals": "^15.9.0",
64
66
  "jsdom": "^24.1.1",
65
67
  "prettier": "^3.3.3",
66
- "publint": "^0.2.9",
68
+ "publint": "^0.2.10",
67
69
  "rimraf": "^6.0.1",
68
70
  "tslib": "^2.6.3",
71
+ "tsx": "^4.17.0",
69
72
  "typescript": "^5.5.4",
70
- "vite": "^5.4.0",
73
+ "vite": "^5.4.1",
71
74
  "vitest": "^2.0.5",
72
75
  "vitest-mock-extended": "^2.0.0"
73
76
  },
@@ -78,13 +81,14 @@
78
81
  "test:watch": "vitest dev",
79
82
  "test:ui": "vitest --coverage.enabled=true --ui",
80
83
  "test:coverage": "vitest run --coverage",
81
- "replaceTokens": "LATEST=${npm_package_version} replacetokens --sources ./dist/version.* --log-level error --missing-var-action keep --use-env > /dev/null",
82
- "build": "tsc --build && pnpm run replaceTokens && publint",
84
+ "build": "tsc --build",
83
85
  "build:clean": "pnpm run clean && pnpm run build",
84
- "build:watch": "tsc --build --watch",
85
- "format": "prettier --write \"src/**/*.+(js|ts|json)\"",
86
- "lint": "eslint --ext .ts src",
86
+ "build:readme": "LATEST=${npm_package_version} tsx ../shared/scripts/replace-readme-tokens.ts ./packages/client",
87
+ "replaceTokens": "LATEST=${npm_package_version} tsx ../shared/scripts/replace-tokens.ts ./packages/client",
88
+ "build:production": "pnpm run build:clean && pnpm run replaceTokens && echo '' && publint",
89
+ "format": "prettier --write \"(src|scripts)/**/*.+(js|ts|json)\"",
90
+ "lint": "eslint ./src",
87
91
  "lint:fix": "pnpm run lint --fix",
88
- "upgrade:deps": "ncu --peer -x effect -x @effect/* -u"
92
+ "upgrade:deps": "ncu --peer -x effect -x @effect/* -i -u"
89
93
  }
90
94
  }
@@ -1,3 +1,5 @@
1
+ import { Effect as E, Layer as L, Option as O } from 'effect'
2
+
1
3
  import {
2
4
  OptionsRes,
3
5
  VerificationReq,
@@ -5,9 +7,9 @@ import {
5
7
  } from '@passlock/shared/dist/rpc/authentication.js'
6
8
  import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
7
9
  import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js'
8
- import { Effect as E, Layer as L, Option as O } from 'effect'
9
- import { AuthenticationClient } from '../rpc/authentication.js'
10
+
10
11
  import * as Fixtures from '../test/fixtures.js'
12
+ import { AuthenticationClient } from '../rpc/authentication.js'
11
13
  import { type AuthenticationRequest, GetCredential } from './authenticate.js'
12
14
 
13
15
  export const session = 'session'
@@ -1,9 +1,10 @@
1
1
  import { Effect as E, Layer as L, Layer, LogLevel, Logger, Option as O, pipe } from 'effect'
2
2
  import { describe, expect, test, vi } from 'vitest'
3
3
  import { mock } from 'vitest-mock-extended'
4
+
5
+ import * as Fixture from './authenticate.fixture.js'
4
6
  import { AuthenticationClient } from '../rpc/authentication.js'
5
7
  import { StorageService } from '../storage/storage.js'
6
- import * as Fixture from './authenticate.fixture.js'
7
8
  import { AuthenticateServiceLive, AuthenticationService, GetCredential } from './authenticate.js'
8
9
 
9
10
  describe('authenticate should', () => {
@@ -5,6 +5,8 @@ import {
5
5
  type CredentialRequestOptionsJSON,
6
6
  parseRequestOptionsFromJSON,
7
7
  } from '@github/webauthn-json/browser-ponyfill'
8
+ import { Context, Effect as E, Layer, flow, pipe } from 'effect'
9
+
8
10
  import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js'
9
11
  import {
10
12
  type OptionsErrors,
@@ -14,7 +16,7 @@ import {
14
16
  } from '@passlock/shared/dist/rpc/authentication.js'
15
17
  import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js'
16
18
  import type { Principal } from '@passlock/shared/dist/schema/principal.js'
17
- import { Context, Effect as E, Layer, flow, pipe } from 'effect'
19
+
18
20
  import { Capabilities } from '../capabilities/capabilities.js'
19
21
  import { AuthenticationClient } from '../rpc/authentication.js'
20
22
  import { StorageService } from '../storage/storage.js'
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Test if the browser supports passkeys, conditional UI etc
3
3
  */
4
- import { NotSupported } from '@passlock/shared/dist/error/error.js'
5
4
  import { Context, Effect as E, Layer, identity, pipe } from 'effect'
6
5
 
6
+ import { NotSupported } from '@passlock/shared/dist/error/error.js'
7
+
7
8
  /* Service */
8
9
 
9
10
  export class Capabilities extends Context.Tag('@services/Capabilities')<
@@ -1,5 +1,7 @@
1
- import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js'
2
1
  import { Effect as E, Layer as L } from 'effect'
2
+
3
+ import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js'
4
+
3
5
  import { ConnectionClient } from '../rpc/connection.js'
4
6
 
5
7
  export const preConnectRes = new ConnectRes({ warmed: true })
@@ -1,10 +1,11 @@
1
1
  import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
2
2
  import { describe, expect, test } from 'vitest'
3
3
  import { mock } from 'vitest-mock-extended'
4
+
5
+ import * as Fixture from './connection.fixture.js'
4
6
  import { Dispatcher } from '../rpc/client.js'
5
7
  import { RpcConfig } from '../rpc/config.js'
6
8
  import { ConnectionClient } from '../rpc/connection.js'
7
- import * as Fixture from './connection.fixture.js'
8
9
  import { ConnectionService, ConnectionServiceLive } from './connection.js'
9
10
 
10
11
  describe('preConnect should', () => {
@@ -2,6 +2,7 @@
2
2
  * Hits the rpc endpoint to warm up a lambda
3
3
  */
4
4
  import { Context, Effect as E, Layer, flow, pipe } from 'effect'
5
+
5
6
  import { Dispatcher } from '../rpc/client.js'
6
7
  import type { RpcConfig } from '../rpc/config.js'
7
8
  import { ConnectionClient } from '../rpc/connection.js'
package/src/effect.ts CHANGED
@@ -1,25 +1,14 @@
1
1
  import { create, get as getCredential } from '@github/webauthn-json/browser-ponyfill'
2
+ import { Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect'
3
+ import type { NoSuchElementException } from 'effect/Cause'
2
4
 
3
5
  import {
4
6
  type BadRequest,
5
7
  Duplicate,
6
8
  InternalBrowserError,
7
9
  } from '@passlock/shared/dist/error/error.js'
8
-
9
- import { AuthenticationClientLive } from './rpc/authentication.js'
10
- import { DispatcherLive } from './rpc/client.js'
11
- import type { RpcConfig } from './rpc/config.js'
12
- import { RetrySchedule } from './rpc/config.js'
13
- import { ConnectionClientLive } from './rpc/connection.js'
14
- import { RegistrationClientLive } from './rpc/registration.js'
15
- import { SocialClientLive } from './rpc/social.js'
16
- import { UserClientLive } from './rpc/user.js'
17
-
18
10
  import type { Principal } from '@passlock/shared/dist/schema/principal.js'
19
11
 
20
- import { Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect'
21
- import type { NoSuchElementException } from 'effect/Cause'
22
-
23
12
  import {
24
13
  AuthenticateServiceLive,
25
14
  type AuthenticationErrors,
@@ -27,7 +16,6 @@ import {
27
16
  AuthenticationService,
28
17
  GetCredential,
29
18
  } from './authentication/authenticate.js'
30
-
31
19
  import { Capabilities, capabilitiesLive } from './capabilities/capabilities.js'
32
20
  import { ConnectionService, ConnectionServiceLive } from './connection/connection.js'
33
21
  import {
@@ -37,7 +25,6 @@ import {
37
25
  type VerifyEmailErrors,
38
26
  type VerifyRequest,
39
27
  } from './email/email.js'
40
-
41
28
  import {
42
29
  CreateCredential,
43
30
  type RegistrationErrors,
@@ -45,7 +32,14 @@ import {
45
32
  RegistrationService,
46
33
  RegistrationServiceLive,
47
34
  } from './registration/register.js'
48
-
35
+ import { AuthenticationClientLive } from './rpc/authentication.js'
36
+ import { DispatcherLive } from './rpc/client.js'
37
+ import type { RpcConfig } from './rpc/config.js'
38
+ import { RetrySchedule } from './rpc/config.js'
39
+ import { ConnectionClientLive } from './rpc/connection.js'
40
+ import { RegistrationClientLive } from './rpc/registration.js'
41
+ import { SocialClientLive } from './rpc/social.js'
42
+ import { UserClientLive } from './rpc/user.js'
49
43
  import {
50
44
  type AuthenticateOidcReq,
51
45
  type AuthenticationErrors as OidcAuthenticationErrors,
@@ -61,7 +55,6 @@ import {
61
55
  StorageServiceLive,
62
56
  type StoredToken,
63
57
  } from './storage/storage.js'
64
-
65
58
  import {
66
59
  type Email,
67
60
  type ResendEmail,
@@ -216,7 +209,8 @@ export const registerPasskey = (
216
209
 
217
210
  export const authenticatePasskey = (
218
211
  request: AuthenticationRequest,
219
- ): E.Effect<Principal, AuthenticationErrors, RpcConfig> => pipe(
212
+ ): E.Effect<Principal, AuthenticationErrors, RpcConfig> =>
213
+ pipe(
220
214
  AuthenticationService,
221
215
  E.flatMap(service => service.authenticatePasskey(request)),
222
216
  E.provide(authenticationServiceLive),
@@ -1,8 +1,10 @@
1
- import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
2
1
  import { Effect as E, Layer as L, Option as O } from 'effect'
2
+
3
+ import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
4
+
5
+ import * as Fixtures from '../test/fixtures.js'
3
6
  import { AuthenticationService } from '../authentication/authenticate.js'
4
7
  import { UserClient } from '../rpc/user.js'
5
- import * as Fixtures from '../test/fixtures.js'
6
8
  import { URLQueryString } from './email.js'
7
9
 
8
10
  export const token = 'token'
@@ -2,10 +2,11 @@ import { Effect as E, Layer as L, LogLevel, Logger, pipe } from 'effect'
2
2
  import { NoSuchElementException } from 'effect/Cause'
3
3
  import { describe, expect, test } from 'vitest'
4
4
  import { mock } from 'vitest-mock-extended'
5
+
6
+ import * as Fixture from './email.fixture.js'
5
7
  import { AuthenticationService } from '../authentication/authenticate.js'
6
8
  import { UserClient } from '../rpc/user.js'
7
9
  import { StorageService } from '../storage/storage.js'
8
- import * as Fixture from './email.fixture.js'
9
10
  import { EmailService, EmailServiceLive } from './email.js'
10
11
 
11
12
  describe('verifyEmailCode should', () => {
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Email verification effects
3
3
  */
4
+ import { Context, Effect as E, Layer, Option as O, flow, identity, pipe } from 'effect'
5
+
4
6
  import { BadRequest } from '@passlock/shared/dist/error/error.js'
5
7
  import type { VerifyEmailErrors as RpcErrors } from '@passlock/shared/dist/rpc/user.js'
6
8
  import { VerifyEmailReq } from '@passlock/shared/dist/rpc/user.js'
7
9
  import type { Principal } from '@passlock/shared/dist/schema/principal.js'
8
- import { Context, Effect as E, Layer, Option as O, flow, identity, pipe } from 'effect'
10
+
9
11
  import { type AuthenticationErrors, AuthenticationService } from '../authentication/authenticate.js'
10
12
  import { UserClient } from '../rpc/user.js'
11
13
  import { StorageService, type StoredToken } from '../storage/storage.js'
@@ -1,5 +1,6 @@
1
1
  import { Effect, pipe } from 'effect'
2
2
  import { describe, expect, test } from 'vitest'
3
+
3
4
  import { fireEvent } from './event.js'
4
5
 
5
6
  // @vitest-environment node
@@ -1,5 +1,6 @@
1
1
  import { Effect } from 'effect'
2
2
  import { afterEach, describe, expect, test, vi } from 'vitest'
3
+
3
4
  import { DebugMessage, fireEvent, isPasslockEvent } from './event.js'
4
5
 
5
6
  describe('fireEvent', () => {
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Fire DOM events
3
3
  */
4
- import { InternalBrowserError } from '@passlock/shared/dist/error/error.js'
5
4
  import { Effect } from 'effect'
6
5
 
6
+ import { InternalBrowserError } from '@passlock/shared/dist/error/error.js'
7
+
7
8
  export const DebugMessage = 'PasslogDebugMessage'
8
9
 
9
10
  export const fireEvent = (message: string) => {
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { Effect as E, Layer as L, Layer, Option as O, Runtime, Scope, pipe } from 'effect'
2
+ import { dual } from 'effect/Function'
3
+
1
4
  import type {
2
5
  BadRequest,
3
6
  Disabled,
@@ -7,20 +10,14 @@ import type {
7
10
  NotSupported,
8
11
  Unauthorized,
9
12
  } from '@passlock/shared/dist/error/error.js'
10
-
11
13
  import { ErrorCode } from '@passlock/shared/dist/error/error.js'
12
14
  import type { VerifyEmail } from '@passlock/shared/dist/schema/email.js'
13
15
  import type { UserVerification } from '@passlock/shared/dist/schema/passkey.js'
14
16
  import type { Principal, UserPrincipal } from '@passlock/shared/dist/schema/principal.js'
15
- import { RpcConfig } from './rpc/config.js'
16
-
17
- import { Effect as E, Layer as L, Layer, Option as O, Runtime, Scope, pipe } from 'effect'
18
17
 
19
18
  import type { AuthenticationService } from './authentication/authenticate.js'
20
19
  import type { Capabilities } from './capabilities/capabilities.js'
21
20
  import type { ConnectionService } from './connection/connection.js'
22
-
23
- import { dual } from 'effect/Function'
24
21
  import {
25
22
  allRequirements,
26
23
  authenticateOidc,
@@ -38,6 +35,7 @@ import {
38
35
  } from './effect.js'
39
36
  import type { EmailService, VerifyRequest } from './email/email.js'
40
37
  import type { RegistrationService } from './registration/register.js'
38
+ import { RpcConfig } from './rpc/config.js'
41
39
  import type { Provider, SocialService } from './social/social.js'
42
40
  import {
43
41
  type AuthType,
@@ -193,7 +191,7 @@ const transformErrors = <A, R>(
193
191
  },
194
192
 
195
193
  Interrupt: () => {
196
- console.error("Interrupt")
194
+ console.error('Interrupt')
197
195
  return E.succeed(new PasslockError('Operation aborted', ErrorCode.InternalBrowserError))
198
196
  },
199
197
 
@@ -207,7 +205,7 @@ const transformErrors = <A, R>(
207
205
 
208
206
  Parallel: errors => {
209
207
  console.error(errors)
210
-
208
+
211
209
  return E.succeed(
212
210
  new PasslockError('Sorry, something went wrong', ErrorCode.InternalServerError),
213
211
  )
@@ -252,15 +250,24 @@ export class PasslockUnsafe {
252
250
  }
253
251
 
254
252
  private readonly runPromise: {
255
- <A, R extends Requirements>(options: Options | undefined): (effect: E.Effect<A, PasslockErrors, R>) => Promise<A>
256
- <A, R extends Requirements>(effect: E.Effect<A, PasslockErrors, R>, options: Options | undefined): Promise<A>
253
+ <A, R extends Requirements>(
254
+ options: Options | undefined,
255
+ ): (effect: E.Effect<A, PasslockErrors, R>) => Promise<A>
256
+ <A, R extends Requirements>(
257
+ effect: E.Effect<A, PasslockErrors, R>,
258
+ options: Options | undefined,
259
+ ): Promise<A>
257
260
  } = dual(
258
261
  2,
259
- <A, R extends Requirements>(effect: E.Effect<A, PasslockErrors, R>, options: Options | undefined): Promise<A> => pipe(
260
- transformErrors(effect),
261
- E.flatMap(result => (PasslockError.isError(result) ? E.fail(result) : E.succeed(result))),
262
- effect => Runtime.runPromise(this.runtime)(effect, options)
263
- )
262
+ <A, R extends Requirements>(
263
+ effect: E.Effect<A, PasslockErrors, R>,
264
+ options: Options | undefined,
265
+ ): Promise<A> =>
266
+ pipe(
267
+ transformErrors(effect),
268
+ E.flatMap(result => (PasslockError.isError(result) ? E.fail(result) : E.succeed(result))),
269
+ effect => Runtime.runPromise(this.runtime)(effect, options),
270
+ ),
264
271
  )
265
272
 
266
273
  preConnect = (options?: Options): Promise<void> => pipe(preConnect(), this.runPromise(options))
@@ -316,7 +323,7 @@ export class Passlock {
316
323
  const scope = E.runSync(Scope.make())
317
324
 
318
325
  this.runtime = E.runSync(Layer.toRuntime(allLayers).pipe(Scope.extend(scope)))
319
-
326
+
320
327
  E.runSync(E.logDebug(`Passlock version: ${PASSLOCK_CLIENT_VERSION}`))
321
328
  }
322
329
 
@@ -330,22 +337,24 @@ export class Passlock {
330
337
  }
331
338
 
332
339
  private readonly runPromise: {
333
- <A, R extends Requirements>(options: Options | undefined): (effect: E.Effect<A, PasslockErrors, R>) => Promise<A | PasslockError>
334
- <A, R extends Requirements>(effect: E.Effect<A, PasslockErrors, R>, options: Options | undefined): Promise<A | PasslockError>
340
+ <A, R extends Requirements>(
341
+ options: Options | undefined,
342
+ ): (effect: E.Effect<A, PasslockErrors, R>) => Promise<A | PasslockError>
343
+ <A, R extends Requirements>(
344
+ effect: E.Effect<A, PasslockErrors, R>,
345
+ options: Options | undefined,
346
+ ): Promise<A | PasslockError>
335
347
  } = dual(
336
348
  2,
337
- <A, R extends Requirements>(effect: E.Effect<A, PasslockErrors, R>, options: Options | undefined): Promise<A | PasslockError> => pipe(
338
- transformErrors(effect),
339
- effect => Runtime.runPromise(this.runtime)(effect, options)
340
- )
349
+ <A, R extends Requirements>(
350
+ effect: E.Effect<A, PasslockErrors, R>,
351
+ options: Options | undefined,
352
+ ): Promise<A | PasslockError> =>
353
+ pipe(transformErrors(effect), effect => Runtime.runPromise(this.runtime)(effect, options)),
341
354
  )
342
355
 
343
356
  preConnect = async (options?: Options): Promise<boolean | PasslockError> => {
344
- return pipe(
345
- preConnect(),
346
- E.as(true),
347
- this.runPromise(options)
348
- )
357
+ return pipe(preConnect(), E.as(true), this.runPromise(options))
349
358
  }
350
359
 
351
360
  isPasskeySupport = (): Promise<boolean> =>
@@ -363,13 +372,10 @@ export class Passlock {
363
372
  authenticatePasskey = (
364
373
  request: AuthenticationRequest = {},
365
374
  options?: Options,
366
- ): Promise<Principal | PasslockError> => pipe(
367
- toRpcAuthenticationRequest(request),
368
- authenticatePasskey,
369
- this.runPromise(options)
370
- )
375
+ ): Promise<Principal | PasslockError> =>
376
+ pipe(toRpcAuthenticationRequest(request), authenticatePasskey, this.runPromise(options))
371
377
 
372
- registerOidc = (request: RegisterOidcReq, options?: Options) =>
378
+ registerOidc = (request: RegisterOidcReq, options?: Options) =>
373
379
  pipe(registerOidc(toRpcRegisterOidcReq(request)), this.runPromise(options))
374
380
 
375
381
  authenticateOidc = (request: AuthenticateOidcReq, options?: Options) =>
@@ -1,5 +1,6 @@
1
1
  import { Effect as E, LogLevel, Logger } from 'effect'
2
2
  import { describe, expect, test, vi } from 'vitest'
3
+
3
4
  import { eventLoggerLive, logRaw } from './eventLogger.js'
4
5
 
5
6
  /**
@@ -25,7 +25,7 @@ const dispatch = (message: string) => {
25
25
  try {
26
26
  const evt = new CustomEvent(DebugMessage, { detail: message })
27
27
  globalThis.dispatchEvent(evt)
28
- } catch (e) {
28
+ } catch {
29
29
  globalThis.console.log('Unable to fire custom event')
30
30
  }
31
31
  }
@@ -1,3 +1,5 @@
1
+ import { Effect as E, Layer as L, Option as O } from 'effect'
2
+
1
3
  import {
2
4
  OptionsReq,
3
5
  OptionsRes,
@@ -5,9 +7,9 @@ import {
5
7
  VerificationRes,
6
8
  } from '@passlock/shared/dist/rpc/registration.js'
7
9
  import type { RegistrationCredential } from '@passlock/shared/dist/schema/passkey.js'
8
- import { Effect as E, Layer as L, Option as O } from 'effect'
9
- import { RegistrationClient } from '../rpc/registration.js'
10
+
10
11
  import * as Fixtures from '../test/fixtures.js'
12
+ import { RegistrationClient } from '../rpc/registration.js'
11
13
  import { UserService } from '../user/user.js'
12
14
  import { CreateCredential, type RegistrationRequest } from './register.js'
13
15
 
@@ -1,9 +1,11 @@
1
- import { Duplicate, InternalBrowserError } from '@passlock/shared/dist/error/error.js'
2
1
  import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
3
2
  import { describe, expect, test, vi } from 'vitest'
4
3
  import { mock } from 'vitest-mock-extended'
5
- import { RegistrationClient } from '../rpc/registration.js'
4
+
5
+ import { Duplicate, InternalBrowserError } from '@passlock/shared/dist/error/error.js'
6
+
6
7
  import * as Fixture from './register.fixture.js'
8
+ import { RegistrationClient } from '../rpc/registration.js'
7
9
  import { CreateCredential, RegistrationService, RegistrationServiceLive } from './register.js'
8
10
 
9
11
  describe('register should', () => {
@@ -5,16 +5,15 @@ import {
5
5
  type CredentialCreationOptionsJSON,
6
6
  parseCreationOptionsFromJSON,
7
7
  } from '@github/webauthn-json/browser-ponyfill'
8
+ import { Context, Effect as E, Layer, flow, pipe } from 'effect'
9
+
8
10
  import type { Duplicate, NotSupported } from '@passlock/shared/dist/error/error.js'
9
11
  import { InternalBrowserError } from '@passlock/shared/dist/error/error.js'
10
12
  import type { OptionsErrors, VerificationErrors } from '@passlock/shared/dist/rpc/registration.js'
11
- import {
12
- OptionsReq,
13
- VerificationReq,
14
- } from '@passlock/shared/dist/rpc/registration.js'
13
+ import { OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/registration.js'
15
14
  import type { RegistrationCredential } from '@passlock/shared/dist/schema/passkey.js'
16
15
  import type { Principal } from '@passlock/shared/dist/schema/principal.js'
17
- import { Context, Effect as E, Layer, flow, pipe } from 'effect'
16
+
18
17
  import { Capabilities } from '../capabilities/capabilities.js'
19
18
  import { RegistrationClient } from '../rpc/registration.js'
20
19
  import { StorageService } from '../storage/storage.js'
@@ -1,5 +1,17 @@
1
- import { OPTIONS_ENDPOINT, OptionsErrors, OptionsReq, OptionsRes, VerificationErrors, VerificationReq, VerificationRes, VERIFY_ENDPOINT, type AuthenticationService } from '@passlock/shared/dist/rpc/authentication.js'
2
1
  import { Context, Effect as E, Layer } from 'effect'
2
+
3
+ import {
4
+ type AuthenticationService,
5
+ OPTIONS_ENDPOINT,
6
+ OptionsErrors,
7
+ OptionsReq,
8
+ OptionsRes,
9
+ VERIFY_ENDPOINT,
10
+ VerificationErrors,
11
+ VerificationReq,
12
+ VerificationRes,
13
+ } from '@passlock/shared/dist/rpc/authentication.js'
14
+
3
15
  import { Dispatcher, makePostRequest } from './client.js'
4
16
 
5
17
  /* Client */
@@ -28,4 +40,4 @@ export const AuthenticationClientLive = Layer.effect(
28
40
  verifyAuthenticationCredential: req => verifyResolver(VERIFY_ENDPOINT, req),
29
41
  }
30
42
  }),
31
- )
43
+ )
package/src/rpc/client.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as S from '@effect/schema/Schema'
2
- import { NetworkError } from '@passlock/shared/dist/error/error.js'
3
2
  import { Context, Effect as E, Layer, pipe } from 'effect'
3
+
4
+ import { NetworkError } from '@passlock/shared/dist/error/error.js'
5
+
4
6
  import { PASSLOCK_CLIENT_VERSION } from '../version.js'
5
7
  import { RetrySchedule, RpcConfig } from './config.js'
6
8
 
@@ -27,7 +29,6 @@ export const DispatcherLive = Layer.effect(
27
29
  const { schedule } = yield* _(RetrySchedule)
28
30
  const { tenancyId, clientId, endpoint: maybeEndpoint } = yield* _(RpcConfig)
29
31
 
30
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
31
32
  const parseJson = (res: Response, url: string) =>
32
33
  E.tryPromise({
33
34
  try: () => res.json() as Promise<unknown>,
@@ -73,7 +74,7 @@ export const DispatcherLive = Layer.effect(
73
74
  const headers = {
74
75
  'Accept': 'application/json',
75
76
  'X-CLIENT-ID': clientId,
76
- 'X-PASSLOCK-CLIENT-VERSION': PASSLOCK_CLIENT_VERSION
77
+ 'X-PASSLOCK-CLIENT-VERSION': PASSLOCK_CLIENT_VERSION,
77
78
  }
78
79
 
79
80
  const url = buildUrl(path)
@@ -102,7 +103,7 @@ export const DispatcherLive = Layer.effect(
102
103
  'Content-Type': 'application/json',
103
104
  'Accept': 'application/json',
104
105
  'X-CLIENT-ID': clientId,
105
- 'X-PASSLOCK-CLIENT-VERSION': PASSLOCK_CLIENT_VERSION
106
+ 'X-PASSLOCK-CLIENT-VERSION': PASSLOCK_CLIENT_VERSION,
106
107
  }
107
108
 
108
109
  // drop leading /