@dynamic-labs/embedded-wallet 4.0.0-alpha.5 → 4.0.0-alpha.51

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.
@@ -10,16 +10,18 @@ var utils = require('@dynamic-labs/utils');
10
10
  var PasskeyService = require('../utils/PasskeyService/PasskeyService.cjs');
11
11
  require('../utils/convertAttestationTransports/convertAttestationTransports.cjs');
12
12
  var logger = require('../utils/logger/logger.cjs');
13
+ var BaseTurnkeyHandler = require('../BaseTurnkeyHandler.cjs');
14
+ var constants = require('../constants.cjs');
13
15
 
14
- const turnkeyBaseUrl = 'https://api.turnkey.com';
15
16
  const turnkeyPasskeyRecoveryUrl = 'https://recovery.turnkey.com';
16
17
  const turnkeyEmailRecoveryUrl = 'https://auth.turnkey.com';
17
18
  const TURNKEY_RECOVERY_CREDENTIAL_EXPIRATION_SECONDS = 900; // 15 seconds
18
19
  const TURNKEY_SESSION_EXPIRATION_SECONDS = 1800; //30 seconds
19
20
  const EMAIL_AUTH_CREDENTIAL_TYPE = 'CREDENTIAL_TYPE_API_KEY_P256';
20
21
  const PASSKEY_RECOVERY_CREDENTIAL_TYPE = 'CREDENTIAL_TYPE_RECOVER_USER_KEY_P256';
21
- class TurnkeyAuthenticatorRecoveryHandler {
22
+ class TurnkeyAuthenticatorRecoveryHandler extends BaseTurnkeyHandler.BaseTurnkeyHandler {
22
23
  constructor() {
24
+ super(...arguments);
23
25
  this.isSessionActive = () => {
24
26
  // it's only used for email auth session
25
27
  if (!this.__createdAt || this.__recoveryType !== 'email') {
@@ -37,7 +39,7 @@ class TurnkeyAuthenticatorRecoveryHandler {
37
39
  if (!organizationId || !this.__turnkeyRecoveryUserId) {
38
40
  throw new utils.DynamicError('Cannot proceed with your request');
39
41
  }
40
- const userResponse = yield ((_a = this.__client) === null || _a === void 0 ? void 0 : _a.getUser({
42
+ const userResponse = yield ((_a = this.__turnkeyClient) === null || _a === void 0 ? void 0 : _a.getUser({
41
43
  organizationId,
42
44
  userId: this.__turnkeyRecoveryUserId,
43
45
  }));
@@ -65,12 +67,6 @@ class TurnkeyAuthenticatorRecoveryHandler {
65
67
  return false;
66
68
  };
67
69
  }
68
- get publicKey() {
69
- return this.__publicKey;
70
- }
71
- get client() {
72
- return this.__client;
73
- }
74
70
  get recoveryType() {
75
71
  return this.__recoveryType;
76
72
  }
@@ -81,12 +77,8 @@ class TurnkeyAuthenticatorRecoveryHandler {
81
77
  this.__turnkeyRecoveryUserId = turnkeyRecoveryUserId;
82
78
  }
83
79
  clear() {
84
- var _a;
85
- (_a = this.__iframeStamper) === null || _a === void 0 ? void 0 : _a.clear();
80
+ super.clear();
86
81
  this.__recoveryType = undefined;
87
- this.__iframeStamper = undefined;
88
- this.__publicKey = undefined;
89
- this.__client = undefined;
90
82
  this.__turnkeyRecoveryUserId = undefined;
91
83
  this.__createdAt = undefined;
92
84
  }
@@ -117,8 +109,8 @@ class TurnkeyAuthenticatorRecoveryHandler {
117
109
  }
118
110
  try {
119
111
  yield this.__iframeStamper.injectCredentialBundle(recoveryBundle);
120
- this.__client = new http.TurnkeyClient({
121
- baseUrl: turnkeyBaseUrl,
112
+ this.__turnkeyClient = new http.TurnkeyClient({
113
+ baseUrl: constants.TURNKEY_API_BASE_URL,
122
114
  }, this.__iframeStamper);
123
115
  if (!organizationId || !this.__turnkeyRecoveryUserId) {
124
116
  throw new utils.DynamicError('Cannot proceed with your request');
@@ -138,11 +130,11 @@ class TurnkeyAuthenticatorRecoveryHandler {
138
130
  }
139
131
  completeRecovery(_a) {
140
132
  return _tslib.__awaiter(this, arguments, void 0, function* ({ attestation, challenge, turnkeySubOrganizationId, }) {
141
- if (!this.__client || !this.__turnkeyRecoveryUserId) {
133
+ if (!this.__turnkeyClient || !this.__turnkeyRecoveryUserId) {
142
134
  throw new utils.DynamicError('Cannot proceed with your request');
143
135
  }
144
136
  try {
145
- return this.__client.recoverUser({
137
+ return this.__turnkeyClient.recoverUser({
146
138
  organizationId: turnkeySubOrganizationId,
147
139
  parameters: {
148
140
  authenticator: {
@@ -164,11 +156,11 @@ class TurnkeyAuthenticatorRecoveryHandler {
164
156
  }
165
157
  addPasskeyAuthenticator(_a) {
166
158
  return _tslib.__awaiter(this, arguments, void 0, function* ({ attestation, challenge, turnkeySubOrganizationId, }) {
167
- if (!this.__client || !this.__turnkeyRecoveryUserId) {
159
+ if (!this.__turnkeyClient || !this.__turnkeyRecoveryUserId) {
168
160
  throw new utils.DynamicError('Cannot proceed with your request');
169
161
  }
170
162
  try {
171
- return this.__client.createAuthenticators({
163
+ return this.__turnkeyClient.createAuthenticators({
172
164
  organizationId: turnkeySubOrganizationId,
173
165
  parameters: {
174
166
  authenticators: [
@@ -200,7 +192,7 @@ class TurnkeyAuthenticatorRecoveryHandler {
200
192
  rpId,
201
193
  });
202
194
  const client = new http.TurnkeyClient({
203
- baseUrl: turnkeyBaseUrl,
195
+ baseUrl: constants.TURNKEY_API_BASE_URL,
204
196
  }, stamper);
205
197
  try {
206
198
  const signedRequest = yield client.stampUpdateUser({