@circle-fin/daa-react-native-sdk 0.4.0 → 0.5.0
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/DaaReactNativeSdk.podspec +14 -8
- package/README.md +498 -24
- package/android/build.gradle +12 -7
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +1 -18
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +38 -4
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +139 -6
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +50 -1
- package/build/DaaClient.d.ts +183 -3
- package/build/DaaClient.js +296 -12
- package/build/api/AccountsClient.d.ts +3 -0
- package/build/api/AccountsClient.js +3 -0
- package/build/api/AuthClient.d.ts +17 -42
- package/build/api/AuthClient.js +26 -62
- package/build/api/ContractExecutionsClient.d.ts +114 -0
- package/build/api/ContractExecutionsClient.js +462 -0
- package/build/api/DaaUserClient.d.ts +74 -11
- package/build/api/DaaUserClient.js +84 -17
- package/build/api/TransactionsClient.d.ts +1 -1
- package/build/api/TransactionsClient.js +1 -0
- package/build/api/TransfersClient.d.ts +3 -0
- package/build/api/TransfersClient.js +3 -0
- package/build/api/WithdrawalsClient.d.ts +3 -0
- package/build/api/WithdrawalsClient.js +3 -0
- package/build/api/deviceApproval.d.ts +48 -0
- package/build/api/deviceApproval.js +247 -0
- package/build/api/deviceStatus.d.ts +61 -0
- package/build/api/deviceStatus.js +216 -0
- package/build/api/loginFailure.d.ts +10 -2
- package/build/api/loginFailure.js +33 -2
- package/build/api/signedResource.d.ts +49 -2
- package/build/api/signedResource.js +135 -36
- package/build/auth/RegistrationFlowKey.js +1 -1
- package/build/auth/daaRegistrationNative.d.ts +0 -22
- package/build/auth/daaRegistrationNative.js +3 -29
- package/build/auth/deviceAuthorization.d.ts +17 -3
- package/build/auth/deviceAuthorization.js +60 -8
- package/build/auth/registrationAuthorization.d.ts +2 -2
- package/build/auth/registrationAuthorization.js +13 -10
- package/build/config.d.ts +27 -0
- package/build/config.js +15 -0
- package/build/crypto/matchingCode.d.ts +47 -0
- package/build/crypto/matchingCode.js +93 -0
- package/build/errors.d.ts +150 -33
- package/build/errors.js +208 -47
- package/build/index.d.ts +11 -3
- package/build/models/ContractExecution.d.ts +197 -0
- package/build/models/ContractExecution.js +130 -0
- package/build/models/CreateContractExecutionRequest.d.ts +81 -0
- package/build/models/CreateContractExecutionRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +53 -3
- package/build/models/DaaUserContext.js +33 -2
- package/build/models/DeviceStatus.d.ts +69 -0
- package/build/models/DeviceStatus.js +19 -0
- package/build/models/PendingDeviceApproval.d.ts +121 -0
- package/build/models/PendingDeviceApproval.js +208 -0
- package/build/models/PendingDeviceRegistration.d.ts +162 -23
- package/build/models/PendingDeviceRegistration.js +525 -69
- package/build/models/PreparedContractExecution.d.ts +70 -0
- package/build/models/PreparedContractExecution.js +77 -0
- package/build/models/PreparedSocialLogin.d.ts +19 -26
- package/build/models/PreparedSocialLogin.js +32 -15
- package/build/models/Transaction.d.ts +48 -2
- package/build/models/Transaction.js +52 -4
- package/build/models/codeSecrets.d.ts +100 -0
- package/build/models/codeSecrets.js +321 -0
- package/build/securekey/InMemorySecureKey.d.ts +3 -1
- package/build/securekey/InMemorySecureKey.js +47 -6
- package/build/securekey/NativeSecureKey.d.ts +3 -1
- package/build/securekey/NativeSecureKey.js +204 -27
- package/build/securekey/NativeSecureKeyBridge.d.ts +72 -4
- package/build/securekey/SecureKey.d.ts +128 -8
- package/build/securekey/alias.d.ts +9 -0
- package/build/securekey/alias.js +11 -2
- package/build/securekey/ownerAuthKeyResolver.d.ts +26 -9
- package/build/securekey/ownerAuthKeyResolver.js +35 -20
- package/build/securekey/registration.d.ts +19 -0
- package/build/securekey/registration.js +38 -0
- package/build/securekey/resolveNativeBridge.d.ts +3 -0
- package/build/securekey/resolveNativeBridge.js +88 -7
- package/build/transport/headers.d.ts +11 -0
- package/build/transport/headers.js +36 -0
- package/build/wire/contractExecutionPayload.d.ts +24 -0
- package/build/wire/contractExecutionPayload.js +130 -0
- package/build/wire/daaStatusCodes.d.ts +20 -3
- package/build/wire/daaStatusCodes.js +20 -3
- package/build/wire/deviceContextPayload.d.ts +9 -7
- package/build/wire/deviceContextPayload.js +9 -7
- package/build/wire/deviceRegistrationResultPayload.d.ts +55 -10
- package/build/wire/deviceRegistrationResultPayload.js +116 -82
- package/build/wire/deviceStatusPayload.d.ts +20 -0
- package/build/wire/deviceStatusPayload.js +66 -0
- package/build/wire/instant.js +4 -1
- package/build/wire/pendingRegistrationPayload.d.ts +16 -0
- package/build/wire/pendingRegistrationPayload.js +18 -0
- package/build/wire/socialLoginRequestPayload.d.ts +0 -5
- package/build/wire/socialLoginRequestPayload.js +2 -19
- package/build/wire/transactionPayload.d.ts +2 -2
- package/build/wire/transactionPayload.js +27 -4
- package/ios/DaaRegistrationModule.swift +1 -19
- package/ios/DaaSecureKeyExceptions.swift +53 -5
- package/ios/DaaSecureKeyModule.swift +149 -5
- package/ios/InstallationIdentityStore.swift +43 -7
- package/package.json +1 -1
- package/src/DaaClient.ts +353 -15
- package/src/api/AccountsClient.ts +3 -0
- package/src/api/AuthClient.ts +33 -98
- package/src/api/ContractExecutionsClient.ts +527 -0
- package/src/api/DaaUserClient.ts +92 -17
- package/src/api/TransactionsClient.ts +1 -0
- package/src/api/TransfersClient.ts +3 -0
- package/src/api/WithdrawalsClient.ts +3 -0
- package/src/api/deviceApproval.ts +306 -0
- package/src/api/deviceStatus.ts +238 -0
- package/src/api/loginFailure.ts +39 -2
- package/src/api/signedResource.ts +206 -46
- package/src/auth/RegistrationFlowKey.ts +1 -1
- package/src/auth/daaRegistrationNative.ts +4 -49
- package/src/auth/deviceAuthorization.ts +74 -11
- package/src/auth/registrationAuthorization.ts +12 -9
- package/src/config.ts +36 -0
- package/src/crypto/matchingCode.ts +100 -0
- package/src/errors.ts +309 -52
- package/src/index.ts +36 -1
- package/src/models/ContractExecution.ts +250 -0
- package/src/models/CreateContractExecutionRequest.ts +100 -0
- package/src/models/DaaUserContext.ts +59 -3
- package/src/models/DeviceStatus.ts +50 -0
- package/src/models/PendingDeviceApproval.ts +229 -0
- package/src/models/PendingDeviceRegistration.ts +673 -79
- package/src/models/PreparedContractExecution.ts +128 -0
- package/src/models/PreparedSocialLogin.ts +41 -31
- package/src/models/Transaction.ts +77 -2
- package/src/models/codeSecrets.ts +360 -0
- package/src/securekey/InMemorySecureKey.ts +61 -7
- package/src/securekey/NativeSecureKey.ts +234 -25
- package/src/securekey/NativeSecureKeyBridge.ts +84 -4
- package/src/securekey/SecureKey.ts +138 -8
- package/src/securekey/alias.ts +11 -3
- package/src/securekey/ownerAuthKeyResolver.ts +63 -24
- package/src/securekey/registration.ts +40 -0
- package/src/securekey/resolveNativeBridge.ts +167 -9
- package/src/transport/headers.ts +47 -0
- package/src/wire/contractExecutionPayload.ts +152 -0
- package/src/wire/daaStatusCodes.ts +20 -3
- package/src/wire/deviceContextPayload.ts +9 -7
- package/src/wire/deviceRegistrationResultPayload.ts +156 -98
- package/src/wire/deviceStatusPayload.ts +68 -0
- package/src/wire/instant.ts +4 -1
- package/src/wire/pendingRegistrationPayload.ts +44 -1
- package/src/wire/socialLoginRequestPayload.ts +2 -25
- package/src/wire/transactionPayload.ts +40 -4
- package/build/auth/prepareReceipt.d.ts +0 -150
- package/build/auth/prepareReceipt.js +0 -357
- package/build/crypto/es256Jws.d.ts +0 -56
- package/build/crypto/es256Jws.js +0 -196
- package/src/auth/prepareReceipt.ts +0 -522
- package/src/crypto/es256Jws.ts +0 -240
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A prepared execution in a form an app can store across a restart.
|
|
20
|
+
*
|
|
21
|
+
* `body` is the exact signed request body, base64url-encoded so the bytes
|
|
22
|
+
* survive storage unchanged. `authorization` is the compact Owner JWS bound to
|
|
23
|
+
* those bytes. It authorizes this one request only, but store the record as
|
|
24
|
+
* you would any credential-bearing value, and delete it once the execution is
|
|
25
|
+
* terminal.
|
|
26
|
+
*/
|
|
27
|
+
export type PersistedContractExecution = Readonly<{
|
|
28
|
+
version: 1;
|
|
29
|
+
body: string;
|
|
30
|
+
authorization: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** The redacted shape `JSON.stringify(prepared)` produces. */
|
|
33
|
+
export type PreparedContractExecutionRendering = {
|
|
34
|
+
readonly idempotencyKey: string;
|
|
35
|
+
readonly body: string;
|
|
36
|
+
readonly authorization: string;
|
|
37
|
+
};
|
|
38
|
+
type PreparedParts = Readonly<{
|
|
39
|
+
bodyBytes: Uint8Array;
|
|
40
|
+
authorization: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* A serialized, Owner-authorized contract execution request.
|
|
44
|
+
*
|
|
45
|
+
* Send it with `ContractExecutionsClient.submit`. After a transport failure, a
|
|
46
|
+
* `5xx`, or an app restart, submit the same instance (or the one
|
|
47
|
+
* `ContractExecutionsClient.restore` rebuilds from {@link toPersisted}) again:
|
|
48
|
+
* the retry carries identical bytes and the identical authorization.
|
|
49
|
+
*
|
|
50
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only.
|
|
51
|
+
*/
|
|
52
|
+
export declare class PreparedContractExecution {
|
|
53
|
+
/** The request's idempotency key, which is also the JWS `idempotency_key` claim. */
|
|
54
|
+
readonly idempotencyKey: string;
|
|
55
|
+
/** @internal Constructed only by `ContractExecutionsClient`. */
|
|
56
|
+
constructor(fields: {
|
|
57
|
+
idempotencyKey: string;
|
|
58
|
+
bodyBytes: Uint8Array;
|
|
59
|
+
authorization: string;
|
|
60
|
+
});
|
|
61
|
+
/** The record to store for a retry after restart. See {@link PersistedContractExecution}. */
|
|
62
|
+
toPersisted(): PersistedContractExecution;
|
|
63
|
+
/** The key renders; the body and the authorization do not. */
|
|
64
|
+
toJSON(): PreparedContractExecutionRendering;
|
|
65
|
+
/** The key prints; the body and the authorization do not. */
|
|
66
|
+
toString(): string;
|
|
67
|
+
}
|
|
68
|
+
/** @internal The exact bytes and header a prepared execution sends. A copy of the bytes. */
|
|
69
|
+
export declare function preparedParts(prepared: PreparedContractExecution): PreparedParts;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PreparedContractExecution = void 0;
|
|
21
|
+
exports.preparedParts = preparedParts;
|
|
22
|
+
const base64url_1 = require("../crypto/base64url");
|
|
23
|
+
const errors_1 = require("../errors");
|
|
24
|
+
const redaction_1 = require("./redaction");
|
|
25
|
+
// Module-private, so the bytes and the header are reachable only by the
|
|
26
|
+
// client that sends them and by `toPersisted`, never through a property a
|
|
27
|
+
// logger or a spread would walk.
|
|
28
|
+
const PARTS = new WeakMap();
|
|
29
|
+
/**
|
|
30
|
+
* A serialized, Owner-authorized contract execution request.
|
|
31
|
+
*
|
|
32
|
+
* Send it with `ContractExecutionsClient.submit`. After a transport failure, a
|
|
33
|
+
* `5xx`, or an app restart, submit the same instance (or the one
|
|
34
|
+
* `ContractExecutionsClient.restore` rebuilds from {@link toPersisted}) again:
|
|
35
|
+
* the retry carries identical bytes and the identical authorization.
|
|
36
|
+
*
|
|
37
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only.
|
|
38
|
+
*/
|
|
39
|
+
class PreparedContractExecution {
|
|
40
|
+
/** @internal Constructed only by `ContractExecutionsClient`. */
|
|
41
|
+
constructor(fields) {
|
|
42
|
+
this.idempotencyKey = fields.idempotencyKey;
|
|
43
|
+
PARTS.set(this, Object.freeze({
|
|
44
|
+
// A private copy, so neither the caller of the constructor nor a
|
|
45
|
+
// reader of `toPersisted` can change the bytes a later retry sends.
|
|
46
|
+
bodyBytes: fields.bodyBytes.slice(),
|
|
47
|
+
authorization: fields.authorization,
|
|
48
|
+
}));
|
|
49
|
+
Object.freeze(this);
|
|
50
|
+
}
|
|
51
|
+
/** The record to store for a retry after restart. See {@link PersistedContractExecution}. */
|
|
52
|
+
toPersisted() {
|
|
53
|
+
const parts = preparedParts(this);
|
|
54
|
+
return Object.freeze({
|
|
55
|
+
version: 1,
|
|
56
|
+
body: (0, base64url_1.toBase64Url)(parts.bodyBytes),
|
|
57
|
+
authorization: parts.authorization,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** The key renders; the body and the authorization do not. */
|
|
61
|
+
toJSON() {
|
|
62
|
+
return { idempotencyKey: this.idempotencyKey, body: redaction_1.REDACTED, authorization: redaction_1.REDACTED };
|
|
63
|
+
}
|
|
64
|
+
/** The key prints; the body and the authorization do not. */
|
|
65
|
+
toString() {
|
|
66
|
+
return `PreparedContractExecution(idempotencyKey=${this.idempotencyKey}, body=${redaction_1.REDACTED}, authorization=${redaction_1.REDACTED})`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.PreparedContractExecution = PreparedContractExecution;
|
|
70
|
+
/** @internal The exact bytes and header a prepared execution sends. A copy of the bytes. */
|
|
71
|
+
function preparedParts(prepared) {
|
|
72
|
+
const parts = PARTS.get(prepared);
|
|
73
|
+
if (parts === undefined) {
|
|
74
|
+
throw (0, errors_1.contractViolation)('not a PreparedContractExecution this SDK prepared or restored');
|
|
75
|
+
}
|
|
76
|
+
return Object.freeze({ bodyBytes: parts.bodyBytes.slice(), authorization: parts.authorization });
|
|
77
|
+
}
|
|
@@ -27,7 +27,7 @@ export declare const SOCIAL_SESSION_PATH = "/v1/accounts/auth/sessions";
|
|
|
27
27
|
/**
|
|
28
28
|
* A prepared social login: `PreparedSocialLogin`.
|
|
29
29
|
*
|
|
30
|
-
* The
|
|
30
|
+
* The four public fields are what the consuming application carries through its
|
|
31
31
|
* own provider login. There is deliberately no AuthKey field of any kind — no
|
|
32
32
|
* `authKeyId`, no thumbprint — because AuthKey selection happens *after* the
|
|
33
33
|
* Social Session response, so at this point in the flow no AuthKey has been
|
|
@@ -54,12 +54,6 @@ export declare const SOCIAL_SESSION_PATH = "/v1/accounts/auth/sessions";
|
|
|
54
54
|
* {@link PreparedSocialLogin.abandon} when the user backs out so the native
|
|
55
55
|
* flow-key cache is dropped; dropping this object alone does not.
|
|
56
56
|
*
|
|
57
|
-
* `AuthClient.prepareSocialLogin` checks the Prepare receipt before it
|
|
58
|
-
* constructs this object (`auth/prepareReceipt.ts`, `checkPrepareReceipt`), so
|
|
59
|
-
* an instance only exists for a response that passed that check. Session does
|
|
60
|
-
* not consume receipt claims: it sends `loginRequestId` plus the application's
|
|
61
|
-
* `idToken` and `clientEntityId`.
|
|
62
|
-
*
|
|
63
57
|
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
64
58
|
* the `#` private fields make the type nominal.
|
|
65
59
|
*/
|
|
@@ -68,29 +62,21 @@ export declare class PreparedSocialLogin {
|
|
|
68
62
|
/** Opaque, single-use DAA correlation for this pending registration attempt. */
|
|
69
63
|
readonly loginRequestId: string;
|
|
70
64
|
/**
|
|
71
|
-
* Single-use nonce the application supplies to the social provider.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
65
|
+
* Single-use nonce the application supplies to the social provider. The SDK
|
|
66
|
+
* reaches DAA through the application's own backend and does not
|
|
67
|
+
* authenticate this value, so it is unauthenticated relay output. Do not
|
|
68
|
+
* treat it as proof that the login request came from Circle: bind the login
|
|
69
|
+
* with the application's own OAuth `state` and its authenticated session
|
|
70
|
+
* with its backend.
|
|
77
71
|
*/
|
|
78
72
|
readonly oidcNonce: string;
|
|
79
73
|
/**
|
|
80
74
|
* DAA correlation to bind inside or alongside the application's own OAuth
|
|
81
75
|
* CSRF state. Per the contract it "must not replace app-owned redirect
|
|
82
|
-
* protection". The
|
|
83
|
-
* is
|
|
84
|
-
* application's own `state` is the primary binding for the provider redirect.
|
|
76
|
+
* protection". The SDK does not authenticate it either. The application's own
|
|
77
|
+
* `state` is the primary binding for the provider redirect.
|
|
85
78
|
*/
|
|
86
79
|
readonly oidcState: string;
|
|
87
|
-
/**
|
|
88
|
-
* The DAA-signed Prepare receipt, verified before this object exists. Null
|
|
89
|
-
* when no trust anchor is pinned for the environment, which is every
|
|
90
|
-
* environment in this release: the SDK then ignores any receipt the service
|
|
91
|
-
* sends, and does not hand on one it has not checked.
|
|
92
|
-
*/
|
|
93
|
-
readonly prepareReceiptJws: string | null;
|
|
94
80
|
/**
|
|
95
81
|
* When the login request expires, as ISO-8601 text. The contract declares that
|
|
96
82
|
* string form and the running service sends epoch milliseconds, so the decoder
|
|
@@ -103,13 +89,14 @@ export declare class PreparedSocialLogin {
|
|
|
103
89
|
readonly loginRequestId: string;
|
|
104
90
|
readonly oidcNonce: string;
|
|
105
91
|
readonly oidcState: string;
|
|
106
|
-
readonly prepareReceiptJws: string | null;
|
|
107
92
|
readonly expiresAt: string;
|
|
108
93
|
readonly registrationCodeVerifier: string;
|
|
109
94
|
readonly registrationFlowKey: RegistrationFlowKey;
|
|
110
95
|
readonly idempotencyKey: string;
|
|
111
96
|
readonly transport: DaaTransport;
|
|
112
97
|
readonly resolveAuthKey: (clientEntityId: string) => Promise<OwnerAuthKey>;
|
|
98
|
+
readonly hasRegisteredAuthKey: (clientEntityId: string) => Promise<boolean>;
|
|
99
|
+
readonly addDeviceApproval: boolean;
|
|
113
100
|
});
|
|
114
101
|
/**
|
|
115
102
|
* Exchange the provider ID token for a pending device registration:
|
|
@@ -117,6 +104,11 @@ export declare class PreparedSocialLogin {
|
|
|
117
104
|
*
|
|
118
105
|
* AuthKey selection happens only after a successful response, then the
|
|
119
106
|
* returned `PendingDeviceRegistration` can call Device Registration Complete.
|
|
107
|
+
* With `addDeviceApproval` on, when DAA says a new device would wait for
|
|
108
|
+
* approval and this device has no registered AuthKey for the end user, no key
|
|
109
|
+
* is selected or created here: the result has `confirmationRequired: true`,
|
|
110
|
+
* and `complete({ confirmAddDevice: true })` creates the key once the user
|
|
111
|
+
* confirms (see `PendingDeviceRegistration`).
|
|
120
112
|
*
|
|
121
113
|
* `clientEntityId` is required, and there is no resolve-or-create fallback
|
|
122
114
|
* behind it: the service refuses a Session that omits it. The value names an
|
|
@@ -147,8 +139,9 @@ export declare class PreparedSocialLogin {
|
|
|
147
139
|
/**
|
|
148
140
|
* Drop the native registration-flow key for this attempt.
|
|
149
141
|
*
|
|
150
|
-
* Call this when the user backs out of provider login
|
|
151
|
-
*
|
|
142
|
+
* Call this when the user backs out of provider login, or declines adding
|
|
143
|
+
* this device after `completeSocialSession` (`confirmationRequired`). The JS
|
|
144
|
+
* handle going out of scope does not clear the native process cache. Safe to call more than
|
|
152
145
|
* once. After this, the attempt cannot proceed to Registration Complete.
|
|
153
146
|
*/
|
|
154
147
|
abandon(): Promise<void>;
|
|
@@ -27,7 +27,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
27
27
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
28
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
29
|
};
|
|
30
|
-
var _PreparedSocialLogin_registrationCodeVerifier, _PreparedSocialLogin_registrationFlowKey, _PreparedSocialLogin_idempotencyKey, _PreparedSocialLogin_transport, _PreparedSocialLogin_resolveAuthKey, _PreparedSocialLogin_sessionConsumed;
|
|
30
|
+
var _PreparedSocialLogin_registrationCodeVerifier, _PreparedSocialLogin_registrationFlowKey, _PreparedSocialLogin_idempotencyKey, _PreparedSocialLogin_transport, _PreparedSocialLogin_resolveAuthKey, _PreparedSocialLogin_hasRegisteredAuthKey, _PreparedSocialLogin_addDeviceApproval, _PreparedSocialLogin_sessionConsumed;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.PreparedSocialLogin = exports.SOCIAL_SESSION_PATH = void 0;
|
|
33
33
|
const ownerGrant_1 = require("../auth/ownerGrant");
|
|
@@ -52,7 +52,7 @@ const ID_TOKEN_MAX_LENGTH = 16384;
|
|
|
52
52
|
/**
|
|
53
53
|
* A prepared social login: `PreparedSocialLogin`.
|
|
54
54
|
*
|
|
55
|
-
* The
|
|
55
|
+
* The four public fields are what the consuming application carries through its
|
|
56
56
|
* own provider login. There is deliberately no AuthKey field of any kind — no
|
|
57
57
|
* `authKeyId`, no thumbprint — because AuthKey selection happens *after* the
|
|
58
58
|
* Social Session response, so at this point in the flow no AuthKey has been
|
|
@@ -79,12 +79,6 @@ const ID_TOKEN_MAX_LENGTH = 16384;
|
|
|
79
79
|
* {@link PreparedSocialLogin.abandon} when the user backs out so the native
|
|
80
80
|
* flow-key cache is dropped; dropping this object alone does not.
|
|
81
81
|
*
|
|
82
|
-
* `AuthClient.prepareSocialLogin` checks the Prepare receipt before it
|
|
83
|
-
* constructs this object (`auth/prepareReceipt.ts`, `checkPrepareReceipt`), so
|
|
84
|
-
* an instance only exists for a response that passed that check. Session does
|
|
85
|
-
* not consume receipt claims: it sends `loginRequestId` plus the application's
|
|
86
|
-
* `idToken` and `clientEntityId`.
|
|
87
|
-
*
|
|
88
82
|
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
89
83
|
* the `#` private fields make the type nominal.
|
|
90
84
|
*/
|
|
@@ -96,19 +90,22 @@ class PreparedSocialLogin {
|
|
|
96
90
|
_PreparedSocialLogin_idempotencyKey.set(this, void 0);
|
|
97
91
|
_PreparedSocialLogin_transport.set(this, void 0);
|
|
98
92
|
_PreparedSocialLogin_resolveAuthKey.set(this, void 0);
|
|
93
|
+
_PreparedSocialLogin_hasRegisteredAuthKey.set(this, void 0);
|
|
94
|
+
_PreparedSocialLogin_addDeviceApproval.set(this, void 0);
|
|
99
95
|
_PreparedSocialLogin_sessionConsumed.set(this, false
|
|
100
96
|
/** @internal Constructed only by `AuthClient.prepareSocialLogin`. */
|
|
101
97
|
);
|
|
102
98
|
this.loginRequestId = fields.loginRequestId;
|
|
103
99
|
this.oidcNonce = fields.oidcNonce;
|
|
104
100
|
this.oidcState = fields.oidcState;
|
|
105
|
-
this.prepareReceiptJws = fields.prepareReceiptJws;
|
|
106
101
|
this.expiresAt = fields.expiresAt;
|
|
107
102
|
__classPrivateFieldSet(this, _PreparedSocialLogin_registrationCodeVerifier, fields.registrationCodeVerifier, "f");
|
|
108
103
|
__classPrivateFieldSet(this, _PreparedSocialLogin_registrationFlowKey, fields.registrationFlowKey, "f");
|
|
109
104
|
__classPrivateFieldSet(this, _PreparedSocialLogin_idempotencyKey, fields.idempotencyKey, "f");
|
|
110
105
|
__classPrivateFieldSet(this, _PreparedSocialLogin_transport, fields.transport, "f");
|
|
111
106
|
__classPrivateFieldSet(this, _PreparedSocialLogin_resolveAuthKey, fields.resolveAuthKey, "f");
|
|
107
|
+
__classPrivateFieldSet(this, _PreparedSocialLogin_hasRegisteredAuthKey, fields.hasRegisteredAuthKey, "f");
|
|
108
|
+
__classPrivateFieldSet(this, _PreparedSocialLogin_addDeviceApproval, fields.addDeviceApproval, "f");
|
|
112
109
|
Object.freeze(this);
|
|
113
110
|
}
|
|
114
111
|
/**
|
|
@@ -117,6 +114,11 @@ class PreparedSocialLogin {
|
|
|
117
114
|
*
|
|
118
115
|
* AuthKey selection happens only after a successful response, then the
|
|
119
116
|
* returned `PendingDeviceRegistration` can call Device Registration Complete.
|
|
117
|
+
* With `addDeviceApproval` on, when DAA says a new device would wait for
|
|
118
|
+
* approval and this device has no registered AuthKey for the end user, no key
|
|
119
|
+
* is selected or created here: the result has `confirmationRequired: true`,
|
|
120
|
+
* and `complete({ confirmAddDevice: true })` creates the key once the user
|
|
121
|
+
* confirms (see `PendingDeviceRegistration`).
|
|
120
122
|
*
|
|
121
123
|
* `clientEntityId` is required, and there is no resolve-or-create fallback
|
|
122
124
|
* behind it: the service refuses a Session that omits it. The value names an
|
|
@@ -201,18 +203,32 @@ class PreparedSocialLogin {
|
|
|
201
203
|
// because the service is what validates and binds that value; it is the
|
|
202
204
|
// server-confirmed identity the rest of the ceremony, and every later
|
|
203
205
|
// `forUser` re-resolution, is checked against.
|
|
204
|
-
const
|
|
206
|
+
const boundEntityId = pending.clientEntityId;
|
|
207
|
+
const resolveAuthKey = () => __classPrivateFieldGet(this, _PreparedSocialLogin_resolveAuthKey, "f").call(this, boundEntityId);
|
|
208
|
+
// A new device that would wait for approval: ask the user before a key
|
|
209
|
+
// exists. Without a registered key here, `complete()` creates one only
|
|
210
|
+
// once the app passes the user's confirmation. A registered key (active,
|
|
211
|
+
// or approved and in its cool-down) is resolved now as before, and DAA's
|
|
212
|
+
// registration answer decides. With the switch off the hint is ignored,
|
|
213
|
+
// as `codeSeal` is.
|
|
214
|
+
const confirmationRequired = __classPrivateFieldGet(this, _PreparedSocialLogin_addDeviceApproval, "f") &&
|
|
215
|
+
pending.deviceApproval?.required === true &&
|
|
216
|
+
!(await __classPrivateFieldGet(this, _PreparedSocialLogin_hasRegisteredAuthKey, "f").call(this, boundEntityId));
|
|
205
217
|
return new PendingDeviceRegistration_1.PendingDeviceRegistration({
|
|
206
218
|
registrationHandle: pending.registrationHandle,
|
|
207
219
|
// The service's own echo of the bound entity, decoded from the response,
|
|
208
220
|
// not the argument this method was handed. The response field is what the
|
|
209
221
|
// rest of the ceremony is checked against, so it stays the one source.
|
|
210
|
-
clientEntityId:
|
|
222
|
+
clientEntityId: boundEntityId,
|
|
211
223
|
expiresAt: pending.expiresAt,
|
|
224
|
+
deviceApproval: pending.deviceApproval,
|
|
225
|
+
confirmationRequired,
|
|
212
226
|
transport: __classPrivateFieldGet(this, _PreparedSocialLogin_transport, "f"),
|
|
213
227
|
registrationCodeVerifier: __classPrivateFieldGet(this, _PreparedSocialLogin_registrationCodeVerifier, "f"),
|
|
214
228
|
registrationFlowKey: __classPrivateFieldGet(this, _PreparedSocialLogin_registrationFlowKey, "f"),
|
|
215
|
-
authKey,
|
|
229
|
+
authKey: confirmationRequired ? null : await resolveAuthKey(),
|
|
230
|
+
resolveAuthKey,
|
|
231
|
+
addDeviceApproval: __classPrivateFieldGet(this, _PreparedSocialLogin_addDeviceApproval, "f"),
|
|
216
232
|
});
|
|
217
233
|
}
|
|
218
234
|
catch (error) {
|
|
@@ -223,8 +239,9 @@ class PreparedSocialLogin {
|
|
|
223
239
|
/**
|
|
224
240
|
* Drop the native registration-flow key for this attempt.
|
|
225
241
|
*
|
|
226
|
-
* Call this when the user backs out of provider login
|
|
227
|
-
*
|
|
242
|
+
* Call this when the user backs out of provider login, or declines adding
|
|
243
|
+
* this device after `completeSocialSession` (`confirmationRequired`). The JS
|
|
244
|
+
* handle going out of scope does not clear the native process cache. Safe to call more than
|
|
228
245
|
* once. After this, the attempt cannot proceed to Registration Complete.
|
|
229
246
|
*/
|
|
230
247
|
async abandon() {
|
|
@@ -232,4 +249,4 @@ class PreparedSocialLogin {
|
|
|
232
249
|
}
|
|
233
250
|
}
|
|
234
251
|
exports.PreparedSocialLogin = PreparedSocialLogin;
|
|
235
|
-
_PreparedSocialLogin_registrationCodeVerifier = new WeakMap(), _PreparedSocialLogin_registrationFlowKey = new WeakMap(), _PreparedSocialLogin_idempotencyKey = new WeakMap(), _PreparedSocialLogin_transport = new WeakMap(), _PreparedSocialLogin_resolveAuthKey = new WeakMap(), _PreparedSocialLogin_sessionConsumed = new WeakMap();
|
|
252
|
+
_PreparedSocialLogin_registrationCodeVerifier = new WeakMap(), _PreparedSocialLogin_registrationFlowKey = new WeakMap(), _PreparedSocialLogin_idempotencyKey = new WeakMap(), _PreparedSocialLogin_transport = new WeakMap(), _PreparedSocialLogin_resolveAuthKey = new WeakMap(), _PreparedSocialLogin_hasRegisteredAuthKey = new WeakMap(), _PreparedSocialLogin_addDeviceApproval = new WeakMap(), _PreparedSocialLogin_sessionConsumed = new WeakMap();
|
|
@@ -53,6 +53,8 @@ export type TransactionType = {
|
|
|
53
53
|
readonly kind: 'fee';
|
|
54
54
|
} | {
|
|
55
55
|
readonly kind: 'credit';
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: 'contract_execution';
|
|
56
58
|
} | {
|
|
57
59
|
readonly kind: 'other';
|
|
58
60
|
} | {
|
|
@@ -128,6 +130,43 @@ export type TransactionLocation = TransactionAccountLocation | TransactionBlockc
|
|
|
128
130
|
readonly kind: 'unrecognized';
|
|
129
131
|
readonly rawValue: string | null;
|
|
130
132
|
};
|
|
133
|
+
/** The redacted shape `JSON.stringify`/`toString` produce for a contract-execution summary. */
|
|
134
|
+
export type TransactionContractExecutionRendering = {
|
|
135
|
+
readonly id: string;
|
|
136
|
+
readonly blockchain: string;
|
|
137
|
+
readonly contractAddress: string;
|
|
138
|
+
readonly functionSelector: string | null;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The bounded contract-execution summary on a `contract_execution` activity row
|
|
142
|
+
* (OpenAPI `ContractExecutionActivityDetails`). Full ABI parameters and raw
|
|
143
|
+
* calldata are not part of the activity row; read them with
|
|
144
|
+
* `ContractExecutionsClient.get(id)`.
|
|
145
|
+
*
|
|
146
|
+
* `id`, `blockchain`, and `contractAddress` are required once the summary is
|
|
147
|
+
* present; `functionSelector` (`0x` plus eight hex digits) is optional and
|
|
148
|
+
* decodes to `null` when absent. `blockchain` is a closed set on the service,
|
|
149
|
+
* but it is read as a string here, the same way a blockchain leg's `chain` is,
|
|
150
|
+
* so a chain added later does not fail the row.
|
|
151
|
+
*
|
|
152
|
+
* `contractAddress` is redacted the same way a blockchain leg's `address` is.
|
|
153
|
+
*/
|
|
154
|
+
export declare class TransactionContractExecution {
|
|
155
|
+
#private;
|
|
156
|
+
readonly id: string;
|
|
157
|
+
readonly blockchain: string;
|
|
158
|
+
readonly functionSelector: string | null;
|
|
159
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
160
|
+
constructor(fields: {
|
|
161
|
+
id: string;
|
|
162
|
+
blockchain: string;
|
|
163
|
+
contractAddress: string;
|
|
164
|
+
functionSelector: string | null;
|
|
165
|
+
});
|
|
166
|
+
get contractAddress(): string;
|
|
167
|
+
toJSON(): TransactionContractExecutionRendering;
|
|
168
|
+
toString(): string;
|
|
169
|
+
}
|
|
131
170
|
/** The redacted shape `JSON.stringify(transaction)` produces. */
|
|
132
171
|
export type TransactionRendering = {
|
|
133
172
|
readonly id: string;
|
|
@@ -139,6 +178,7 @@ export type TransactionRendering = {
|
|
|
139
178
|
};
|
|
140
179
|
readonly source: TransactionLocation | null;
|
|
141
180
|
readonly destination: TransactionLocation | null;
|
|
181
|
+
readonly contractExecution: TransactionContractExecutionRendering | null;
|
|
142
182
|
readonly createDate: string;
|
|
143
183
|
readonly updateDate: string;
|
|
144
184
|
};
|
|
@@ -152,11 +192,15 @@ export type TransactionRendering = {
|
|
|
152
192
|
* `updateDate`. Those six are marked required, and every service path that
|
|
153
193
|
* produces a transaction always sets them. `source` and `destination` are
|
|
154
194
|
* documented "when available", and the service omits an absent leg rather than
|
|
155
|
-
* sending JSON `null`.
|
|
195
|
+
* sending JSON `null`. `contractExecution` is present only on a
|
|
196
|
+
* `contract_execution` row (the service sends it on no other type) and is
|
|
197
|
+
* `null` when absent; on such a row
|
|
198
|
+
* `amount` is the requested native value, which may be `"0"`.
|
|
156
199
|
*
|
|
157
200
|
* **`amount` does not appear in any default rendering.** It sits behind a
|
|
158
201
|
* prototype accessor, so `Object.keys`, `JSON.stringify`, spread, `for...in`,
|
|
159
|
-
* and `console.log` do not reach it. A blockchain leg redacts its own address
|
|
202
|
+
* and `console.log` do not reach it. A blockchain leg redacts its own address,
|
|
203
|
+
* and a contract-execution summary redacts its contract address.
|
|
160
204
|
*
|
|
161
205
|
* Not constructible by a consumer: exported from `index.ts` as a type only,
|
|
162
206
|
* and the `#amount` field makes the type nominal.
|
|
@@ -168,6 +212,7 @@ export declare class Transaction {
|
|
|
168
212
|
readonly status: TransactionStatus;
|
|
169
213
|
readonly source: TransactionLocation | null;
|
|
170
214
|
readonly destination: TransactionLocation | null;
|
|
215
|
+
readonly contractExecution: TransactionContractExecution | null;
|
|
171
216
|
readonly createDate: string;
|
|
172
217
|
readonly updateDate: string;
|
|
173
218
|
/** @internal Constructed only by the SDK's response decoder. */
|
|
@@ -178,6 +223,7 @@ export declare class Transaction {
|
|
|
178
223
|
readonly amount: Money;
|
|
179
224
|
readonly source: TransactionLocation | null;
|
|
180
225
|
readonly destination: TransactionLocation | null;
|
|
226
|
+
readonly contractExecution: TransactionContractExecution | null;
|
|
181
227
|
readonly createDate: string;
|
|
182
228
|
readonly updateDate: string;
|
|
183
229
|
});
|
|
@@ -27,9 +27,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
27
27
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
28
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
29
|
};
|
|
30
|
-
var _TransactionBlockchainLocation_address, _TransactionBlockchainLocation_addressTag, _Transaction_amount;
|
|
30
|
+
var _TransactionBlockchainLocation_address, _TransactionBlockchainLocation_addressTag, _TransactionContractExecution_contractAddress, _Transaction_amount;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.Transaction = exports.TransactionBlockchainLocation = void 0;
|
|
32
|
+
exports.Transaction = exports.TransactionContractExecution = exports.TransactionBlockchainLocation = void 0;
|
|
33
33
|
const redaction_1 = require("./redaction");
|
|
34
34
|
/**
|
|
35
35
|
* An on-chain transaction leg (the runtime `BlockchainLocation` class).
|
|
@@ -77,6 +77,48 @@ class TransactionBlockchainLocation {
|
|
|
77
77
|
}
|
|
78
78
|
exports.TransactionBlockchainLocation = TransactionBlockchainLocation;
|
|
79
79
|
_TransactionBlockchainLocation_address = new WeakMap(), _TransactionBlockchainLocation_addressTag = new WeakMap();
|
|
80
|
+
/**
|
|
81
|
+
* The bounded contract-execution summary on a `contract_execution` activity row
|
|
82
|
+
* (OpenAPI `ContractExecutionActivityDetails`). Full ABI parameters and raw
|
|
83
|
+
* calldata are not part of the activity row; read them with
|
|
84
|
+
* `ContractExecutionsClient.get(id)`.
|
|
85
|
+
*
|
|
86
|
+
* `id`, `blockchain`, and `contractAddress` are required once the summary is
|
|
87
|
+
* present; `functionSelector` (`0x` plus eight hex digits) is optional and
|
|
88
|
+
* decodes to `null` when absent. `blockchain` is a closed set on the service,
|
|
89
|
+
* but it is read as a string here, the same way a blockchain leg's `chain` is,
|
|
90
|
+
* so a chain added later does not fail the row.
|
|
91
|
+
*
|
|
92
|
+
* `contractAddress` is redacted the same way a blockchain leg's `address` is.
|
|
93
|
+
*/
|
|
94
|
+
class TransactionContractExecution {
|
|
95
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
96
|
+
constructor(fields) {
|
|
97
|
+
_TransactionContractExecution_contractAddress.set(this, void 0);
|
|
98
|
+
this.id = fields.id;
|
|
99
|
+
this.blockchain = fields.blockchain;
|
|
100
|
+
this.functionSelector = fields.functionSelector;
|
|
101
|
+
__classPrivateFieldSet(this, _TransactionContractExecution_contractAddress, fields.contractAddress, "f");
|
|
102
|
+
Object.freeze(this);
|
|
103
|
+
}
|
|
104
|
+
get contractAddress() {
|
|
105
|
+
return __classPrivateFieldGet(this, _TransactionContractExecution_contractAddress, "f");
|
|
106
|
+
}
|
|
107
|
+
toJSON() {
|
|
108
|
+
return {
|
|
109
|
+
id: this.id,
|
|
110
|
+
blockchain: this.blockchain,
|
|
111
|
+
contractAddress: redaction_1.REDACTED,
|
|
112
|
+
functionSelector: this.functionSelector,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
toString() {
|
|
116
|
+
return (`TransactionContractExecution(id=${this.id}, blockchain=${this.blockchain}, ` +
|
|
117
|
+
`contractAddress=${redaction_1.REDACTED}, functionSelector=${this.functionSelector ?? 'null'})`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.TransactionContractExecution = TransactionContractExecution;
|
|
121
|
+
_TransactionContractExecution_contractAddress = new WeakMap();
|
|
80
122
|
/**
|
|
81
123
|
* A DAA unified activity row (OpenAPI `Transaction`), as
|
|
82
124
|
* `GET /v1/accounts/transactions` reports it.
|
|
@@ -87,11 +129,15 @@ _TransactionBlockchainLocation_address = new WeakMap(), _TransactionBlockchainLo
|
|
|
87
129
|
* `updateDate`. Those six are marked required, and every service path that
|
|
88
130
|
* produces a transaction always sets them. `source` and `destination` are
|
|
89
131
|
* documented "when available", and the service omits an absent leg rather than
|
|
90
|
-
* sending JSON `null`.
|
|
132
|
+
* sending JSON `null`. `contractExecution` is present only on a
|
|
133
|
+
* `contract_execution` row (the service sends it on no other type) and is
|
|
134
|
+
* `null` when absent; on such a row
|
|
135
|
+
* `amount` is the requested native value, which may be `"0"`.
|
|
91
136
|
*
|
|
92
137
|
* **`amount` does not appear in any default rendering.** It sits behind a
|
|
93
138
|
* prototype accessor, so `Object.keys`, `JSON.stringify`, spread, `for...in`,
|
|
94
|
-
* and `console.log` do not reach it. A blockchain leg redacts its own address
|
|
139
|
+
* and `console.log` do not reach it. A blockchain leg redacts its own address,
|
|
140
|
+
* and a contract-execution summary redacts its contract address.
|
|
95
141
|
*
|
|
96
142
|
* Not constructible by a consumer: exported from `index.ts` as a type only,
|
|
97
143
|
* and the `#amount` field makes the type nominal.
|
|
@@ -105,6 +151,7 @@ class Transaction {
|
|
|
105
151
|
this.status = fields.status;
|
|
106
152
|
this.source = fields.source;
|
|
107
153
|
this.destination = fields.destination;
|
|
154
|
+
this.contractExecution = fields.contractExecution;
|
|
108
155
|
this.createDate = fields.createDate;
|
|
109
156
|
this.updateDate = fields.updateDate;
|
|
110
157
|
__classPrivateFieldSet(this, _Transaction_amount, fields.amount, "f");
|
|
@@ -121,6 +168,7 @@ class Transaction {
|
|
|
121
168
|
amount: __classPrivateFieldGet(this, _Transaction_amount, "f").toJSON(),
|
|
122
169
|
source: this.source,
|
|
123
170
|
destination: this.destination,
|
|
171
|
+
contractExecution: this.contractExecution === null ? null : this.contractExecution.toJSON(),
|
|
124
172
|
createDate: this.createDate,
|
|
125
173
|
updateDate: this.updateDate,
|
|
126
174
|
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { OwnerAuthKey } from '../securekey/SecureKey';
|
|
19
|
+
/**
|
|
20
|
+
* Keep `secret` even when a later refusal says no request is waiting. `null`
|
|
21
|
+
* (a registration sent without `addDeviceApproval`, so with no secret) does
|
|
22
|
+
* nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function holdCodeSecret(secret: Uint8Array | null): void;
|
|
25
|
+
/**
|
|
26
|
+
* Runs `step` once every earlier step for the same key has settled: each
|
|
27
|
+
* `complete()` of the key, and each `sendCodeSecret()` deciding what to send.
|
|
28
|
+
*
|
|
29
|
+
* Two overlapping Completes for one key send the same secret. DAA can refuse
|
|
30
|
+
* the first (say, 409 conflict: another device was waiting, so both requests
|
|
31
|
+
* were cancelled) and then add the second as waiting with that secret's seal.
|
|
32
|
+
* If the refusal reached the app last, it would drop the secret the waiting
|
|
33
|
+
* request needs, and the next login would show a code that can't match.
|
|
34
|
+
*/
|
|
35
|
+
export declare function oneAtATime<T>(thumbprint: string, step: () => Promise<T>): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* The secret the key's next registration seals: the one this process holds,
|
|
38
|
+
* else the key's stored one (`authKey.codeSecret()`, which creates it on first
|
|
39
|
+
* use), else, for a key without that method, a new 32-byte one. Call it in the
|
|
40
|
+
* key's {@link oneAtATime} queue.
|
|
41
|
+
*
|
|
42
|
+
* A key must have both `codeSecret` and `deleteCodeSecret`, or neither: with
|
|
43
|
+
* only `codeSecret`, the send couldn't delete the secret and the next
|
|
44
|
+
* registration would read the sent secret back and seal it again.
|
|
45
|
+
*
|
|
46
|
+
* Records nothing once `late()` is true: the queue has moved on, and a
|
|
47
|
+
* registration queued after this one may already have its own secret here.
|
|
48
|
+
*/
|
|
49
|
+
export declare function codeSecretFor(thumbprint: string, authKey: OwnerAuthKey, late: () => boolean): Promise<Uint8Array>;
|
|
50
|
+
/**
|
|
51
|
+
* A registration that sealed `secret` is about to go out: until DAA answers,
|
|
52
|
+
* the request that seal ends up in is unknown.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sealingCodeSecret(thumbprint: string, secret: Uint8Array): void;
|
|
55
|
+
/**
|
|
56
|
+
* The secret behind `requestId`, which DAA returned as waiting after a
|
|
57
|
+
* registration that sealed `sealed`: the sent secret if DAA returned the
|
|
58
|
+
* request it was sent for, else `sealed`, now recorded as sealed into
|
|
59
|
+
* `requestId`. Forgets a sent secret whose request DAA no longer returns,
|
|
60
|
+
* since a key has only one waiting request.
|
|
61
|
+
*
|
|
62
|
+
* `requestSeal` is the request's stored `codeSeal` as DAA returned it. If the
|
|
63
|
+
* chosen secret doesn't open it, returns `null` and records nothing against
|
|
64
|
+
* that request: the request was sealed with a secret this SDK no longer
|
|
65
|
+
* holds, so no code from this device can match it and nothing may be sent for
|
|
66
|
+
* it. `sealed` stays the key's unsent secret, harmless to seal again since it
|
|
67
|
+
* never left the device.
|
|
68
|
+
* A `null` `requestSeal` (a DAA that doesn't return it) is not checked.
|
|
69
|
+
*/
|
|
70
|
+
export declare function codeSecretForRequest(thumbprint: string, thumbprintBytes: Uint8Array, sealed: Uint8Array, requestId: string, requestSeal: string | null): Uint8Array | null;
|
|
71
|
+
/**
|
|
72
|
+
* Whether `secret` may be sent for `requestId`: it was already sent for that
|
|
73
|
+
* request (a retry), or it is the unsent secret DAA last returned that request
|
|
74
|
+
* for. If so, records it as sent, before the request goes out (a send whose
|
|
75
|
+
* response is lost may still have reached DAA): deletes it from the key's
|
|
76
|
+
* storage, so the key's next registration seals a new secret, then keeps it
|
|
77
|
+
* here as `sent`. If that delete throws or passes its time limit
|
|
78
|
+
* ({@link deleteWithinLimit}), nothing changes and nothing may be sent; a
|
|
79
|
+
* retry deletes again. Compares by reference, so `secret` must be the array
|
|
80
|
+
* this module handed out. Call it in the key's {@link oneAtATime} queue.
|
|
81
|
+
*/
|
|
82
|
+
export declare function markCodeSecretSent(thumbprint: string, secret: Uint8Array, requestId: string, authKey: OwnerAuthKey): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* DAA said no request is waiting for the key after a registration that sealed
|
|
85
|
+
* `secret`: forget the key's secrets, unless a later registration or send
|
|
86
|
+
* already replaced `secret`. Compares by reference: don't copy it
|
|
87
|
+
* (`.slice()`) on the way here, or nothing is ever dropped.
|
|
88
|
+
*
|
|
89
|
+
* Returns `true` when it forgot the unsent secret, which the caller then
|
|
90
|
+
* deletes from the key's storage with {@link deleteStoredCodeSecret}. That is
|
|
91
|
+
* left to the caller so a registration can save DAA's answer first.
|
|
92
|
+
*/
|
|
93
|
+
export declare function dropCodeSecret(thumbprint: string, secret: Uint8Array | null): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Delete a secret {@link dropCodeSecret} forgot from the key's storage. A
|
|
96
|
+
* failure or a timeout is ignored: the secret never left the device, so
|
|
97
|
+
* keeping it is harmless, and the next registration reads it back and seals it
|
|
98
|
+
* again.
|
|
99
|
+
*/
|
|
100
|
+
export declare function deleteStoredCodeSecret(authKey: OwnerAuthKey, secret: Uint8Array): Promise<void>;
|