@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.4.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 +63 -0
- package/LICENSE +176 -0
- package/README.md +217 -2
- package/android/build.gradle +97 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
- package/build/DaaClient.d.ts +57 -0
- package/build/DaaClient.js +158 -0
- package/build/api/AccountLimitsClient.d.ts +79 -0
- package/build/api/AccountLimitsClient.js +142 -0
- package/build/api/AccountsClient.d.ts +95 -0
- package/build/api/AccountsClient.js +276 -0
- package/build/api/AchFiatAccountsClient.d.ts +92 -0
- package/build/api/AchFiatAccountsClient.js +142 -0
- package/build/api/AuthClient.d.ts +120 -0
- package/build/api/AuthClient.js +257 -0
- package/build/api/DaaUserClient.d.ts +124 -0
- package/build/api/DaaUserClient.js +245 -0
- package/build/api/DepositAddressesClient.d.ts +112 -0
- package/build/api/DepositAddressesClient.js +222 -0
- package/build/api/DepositsClient.d.ts +106 -0
- package/build/api/DepositsClient.js +183 -0
- package/build/api/FiatAccountsClient.d.ts +43 -0
- package/build/api/FiatAccountsClient.js +46 -0
- package/build/api/TransactionsClient.d.ts +64 -0
- package/build/api/TransactionsClient.js +120 -0
- package/build/api/TransfersClient.d.ts +104 -0
- package/build/api/TransfersClient.js +321 -0
- package/build/api/WireFiatAccountsClient.d.ts +99 -0
- package/build/api/WireFiatAccountsClient.js +156 -0
- package/build/api/WithdrawalsClient.d.ts +94 -0
- package/build/api/WithdrawalsClient.js +305 -0
- package/build/api/loginFailure.d.ts +43 -0
- package/build/api/loginFailure.js +64 -0
- package/build/api/pagination.d.ts +29 -0
- package/build/api/pagination.js +50 -0
- package/build/api/queryParameters.d.ts +23 -0
- package/build/api/queryParameters.js +77 -0
- package/build/api/resourceRequest.d.ts +60 -0
- package/build/api/resourceRequest.js +79 -0
- package/build/api/signedResource.d.ts +77 -0
- package/build/api/signedResource.js +168 -0
- package/build/auth/RegistrationFlowKey.d.ts +93 -0
- package/build/auth/RegistrationFlowKey.js +203 -0
- package/build/auth/daaRegistrationNative.d.ts +80 -0
- package/build/auth/daaRegistrationNative.js +184 -0
- package/build/auth/deviceAuthorization.d.ts +73 -0
- package/build/auth/deviceAuthorization.js +243 -0
- package/build/auth/ownerGrant.d.ts +29 -0
- package/build/auth/ownerGrant.js +90 -0
- package/build/auth/prepareReceipt.d.ts +150 -0
- package/build/auth/prepareReceipt.js +357 -0
- package/build/auth/registrationAuthorization.d.ts +48 -0
- package/build/auth/registrationAuthorization.js +243 -0
- package/build/auth/registrationCodeVerifier.d.ts +31 -0
- package/build/auth/registrationCodeVerifier.js +75 -0
- package/build/config.d.ts +79 -0
- package/build/config.js +116 -0
- package/build/crypto/base64url.d.ts +26 -0
- package/build/crypto/base64url.js +87 -0
- package/build/crypto/bytes.d.ts +27 -0
- package/build/crypto/bytes.js +32 -0
- package/build/crypto/es256Jws.d.ts +56 -0
- package/build/crypto/es256Jws.js +196 -0
- package/build/crypto/jwkThumbprint.d.ts +32 -0
- package/build/crypto/jwkThumbprint.js +49 -0
- package/build/crypto/random.d.ts +35 -0
- package/build/crypto/random.js +106 -0
- package/build/crypto/serialization.d.ts +26 -0
- package/build/crypto/serialization.js +43 -0
- package/build/crypto/sha256.d.ts +18 -0
- package/build/crypto/sha256.js +100 -0
- package/build/errors.d.ts +190 -0
- package/build/errors.js +252 -0
- package/build/index.d.ts +61 -0
- package/build/index.js +67 -0
- package/build/models/Account.d.ts +201 -0
- package/build/models/Account.js +147 -0
- package/build/models/AccountLimitsUsage.d.ts +169 -0
- package/build/models/AccountLimitsUsage.js +86 -0
- package/build/models/Ach.d.ts +135 -0
- package/build/models/Ach.js +184 -0
- package/build/models/AddressObject.d.ts +128 -0
- package/build/models/AddressObject.js +141 -0
- package/build/models/BusinessPii.d.ts +84 -0
- package/build/models/BusinessPii.js +142 -0
- package/build/models/CreateAccountRequest.d.ts +74 -0
- package/build/models/CreateAccountRequest.js +19 -0
- package/build/models/CreateTransferRequest.d.ts +91 -0
- package/build/models/CreateTransferRequest.js +19 -0
- package/build/models/CreateWithdrawalRequest.d.ts +99 -0
- package/build/models/CreateWithdrawalRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +96 -0
- package/build/models/DaaUserContext.js +133 -0
- package/build/models/Deposit.d.ts +241 -0
- package/build/models/Deposit.js +149 -0
- package/build/models/DepositSummary.d.ts +91 -0
- package/build/models/DepositSummary.js +114 -0
- package/build/models/FiatAccount.d.ts +99 -0
- package/build/models/FiatAccount.js +151 -0
- package/build/models/GenerateAddressRequest.d.ts +67 -0
- package/build/models/GenerateAddressRequest.js +68 -0
- package/build/models/Money.d.ts +76 -0
- package/build/models/Money.js +99 -0
- package/build/models/Page.d.ts +33 -0
- package/build/models/Page.js +57 -0
- package/build/models/PendingDeviceRegistration.d.ts +90 -0
- package/build/models/PendingDeviceRegistration.js +180 -0
- package/build/models/PreparedSocialLogin.d.ts +155 -0
- package/build/models/PreparedSocialLogin.js +235 -0
- package/build/models/Transaction.d.ts +187 -0
- package/build/models/Transaction.js +134 -0
- package/build/models/Transfer.d.ts +335 -0
- package/build/models/Transfer.js +240 -0
- package/build/models/Wire.d.ts +213 -0
- package/build/models/Wire.js +264 -0
- package/build/models/Withdrawal.d.ts +201 -0
- package/build/models/Withdrawal.js +156 -0
- package/build/models/redaction.d.ts +18 -0
- package/build/models/redaction.js +23 -0
- package/build/sca/ScaClient.d.ts +105 -0
- package/build/sca/ScaClient.js +193 -0
- package/build/securekey/InMemorySecureKey.d.ts +23 -0
- package/build/securekey/InMemorySecureKey.js +127 -0
- package/build/securekey/NativeSecureKey.d.ts +24 -0
- package/build/securekey/NativeSecureKey.js +178 -0
- package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
- package/build/securekey/NativeSecureKeyBridge.js +19 -0
- package/build/securekey/SecureKey.d.ts +137 -0
- package/build/securekey/SecureKey.js +19 -0
- package/build/securekey/alias.d.ts +88 -0
- package/build/securekey/alias.js +175 -0
- package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
- package/build/securekey/ownerAuthKeyResolver.js +63 -0
- package/build/securekey/resolveNativeBridge.d.ts +30 -0
- package/build/securekey/resolveNativeBridge.js +120 -0
- package/build/testing.d.ts +18 -0
- package/build/testing.js +34 -0
- package/build/transport/DaaTransport.d.ts +35 -0
- package/build/transport/DaaTransport.js +19 -0
- package/build/transport/headers.d.ts +30 -0
- package/build/transport/headers.js +45 -0
- package/build/validation/requestBody.d.ts +27 -0
- package/build/validation/requestBody.js +56 -0
- package/build/validation/uuid.d.ts +25 -0
- package/build/validation/uuid.js +33 -0
- package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
- package/build/wire/accountLimitsUsagePayload.js +130 -0
- package/build/wire/accountPayload.d.ts +36 -0
- package/build/wire/accountPayload.js +100 -0
- package/build/wire/achPayload.d.ts +24 -0
- package/build/wire/achPayload.js +82 -0
- package/build/wire/addressObjectPayload.d.ts +44 -0
- package/build/wire/addressObjectPayload.js +64 -0
- package/build/wire/daaStatusCodes.d.ts +64 -0
- package/build/wire/daaStatusCodes.js +69 -0
- package/build/wire/dataEnvelope.d.ts +40 -0
- package/build/wire/dataEnvelope.js +79 -0
- package/build/wire/depositPayload.d.ts +42 -0
- package/build/wire/depositPayload.js +159 -0
- package/build/wire/deviceContextPayload.d.ts +33 -0
- package/build/wire/deviceContextPayload.js +57 -0
- package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
- package/build/wire/deviceRegistrationResultPayload.js +128 -0
- package/build/wire/errorEnvelope.d.ts +43 -0
- package/build/wire/errorEnvelope.js +85 -0
- package/build/wire/fiatAccountPayload.d.ts +37 -0
- package/build/wire/fiatAccountPayload.js +93 -0
- package/build/wire/instant.d.ts +27 -0
- package/build/wire/instant.js +91 -0
- package/build/wire/jsonNumber.d.ts +30 -0
- package/build/wire/jsonNumber.js +34 -0
- package/build/wire/moneyPayload.d.ts +30 -0
- package/build/wire/moneyPayload.js +56 -0
- package/build/wire/paginationLinks.d.ts +28 -0
- package/build/wire/paginationLinks.js +167 -0
- package/build/wire/payload.d.ts +60 -0
- package/build/wire/payload.js +121 -0
- package/build/wire/pendingRegistrationPayload.d.ts +32 -0
- package/build/wire/pendingRegistrationPayload.js +54 -0
- package/build/wire/socialLoginRequestPayload.d.ts +31 -0
- package/build/wire/socialLoginRequestPayload.js +72 -0
- package/build/wire/transactionPayload.d.ts +31 -0
- package/build/wire/transactionPayload.js +126 -0
- package/build/wire/transferPayload.d.ts +43 -0
- package/build/wire/transferPayload.js +218 -0
- package/build/wire/wireEnums.d.ts +22 -0
- package/build/wire/wireEnums.js +69 -0
- package/build/wire/wirePayload.d.ts +29 -0
- package/build/wire/wirePayload.js +138 -0
- package/build/wire/withdrawalPayload.d.ts +27 -0
- package/build/wire/withdrawalPayload.js +179 -0
- package/expo-module.config.json +14 -0
- package/ios/DaaRegistrationExceptions.swift +58 -0
- package/ios/DaaRegistrationModule.swift +143 -0
- package/ios/DaaScaExceptions.swift +96 -0
- package/ios/DaaScaModule.swift +125 -0
- package/ios/DaaSecureKeyExceptions.swift +77 -0
- package/ios/DaaSecureKeyModule.swift +162 -0
- package/ios/InstallationIdentityStore.swift +126 -0
- package/ios/UnpaddedBase64URL.swift +42 -0
- package/package.json +114 -4
- package/src/DaaClient.ts +171 -0
- package/src/api/AccountLimitsClient.ts +146 -0
- package/src/api/AccountsClient.ts +305 -0
- package/src/api/AchFiatAccountsClient.ts +147 -0
- package/src/api/AuthClient.ts +331 -0
- package/src/api/DaaUserClient.ts +270 -0
- package/src/api/DepositAddressesClient.ts +239 -0
- package/src/api/DepositsClient.ts +208 -0
- package/src/api/FiatAccountsClient.ts +50 -0
- package/src/api/TransactionsClient.ts +137 -0
- package/src/api/TransfersClient.ts +361 -0
- package/src/api/WireFiatAccountsClient.ts +172 -0
- package/src/api/WithdrawalsClient.ts +339 -0
- package/src/api/loginFailure.ts +75 -0
- package/src/api/pagination.ts +63 -0
- package/src/api/queryParameters.ts +82 -0
- package/src/api/resourceRequest.ts +135 -0
- package/src/api/signedResource.ts +267 -0
- package/src/auth/RegistrationFlowKey.ts +274 -0
- package/src/auth/daaRegistrationNative.ts +236 -0
- package/src/auth/deviceAuthorization.ts +302 -0
- package/src/auth/ownerGrant.ts +102 -0
- package/src/auth/prepareReceipt.ts +522 -0
- package/src/auth/registrationAuthorization.ts +306 -0
- package/src/auth/registrationCodeVerifier.ts +76 -0
- package/src/config.ts +156 -0
- package/src/crypto/base64url.ts +88 -0
- package/src/crypto/bytes.ts +30 -0
- package/src/crypto/es256Jws.ts +240 -0
- package/src/crypto/jwkThumbprint.ts +65 -0
- package/src/crypto/random.ts +113 -0
- package/src/crypto/serialization.ts +42 -0
- package/src/crypto/sha256.ts +105 -0
- package/src/errors.ts +319 -0
- package/src/index.ts +223 -0
- package/src/models/Account.ts +264 -0
- package/src/models/AccountLimitsUsage.ts +192 -0
- package/src/models/Ach.ts +269 -0
- package/src/models/AddressObject.ts +169 -0
- package/src/models/BusinessPii.ts +154 -0
- package/src/models/CreateAccountRequest.ts +109 -0
- package/src/models/CreateTransferRequest.ts +114 -0
- package/src/models/CreateWithdrawalRequest.ts +120 -0
- package/src/models/DaaUserContext.ts +172 -0
- package/src/models/Deposit.ts +307 -0
- package/src/models/DepositSummary.ts +142 -0
- package/src/models/FiatAccount.ts +195 -0
- package/src/models/GenerateAddressRequest.ts +101 -0
- package/src/models/Money.ts +91 -0
- package/src/models/Page.ts +48 -0
- package/src/models/PendingDeviceRegistration.ts +197 -0
- package/src/models/PreparedSocialLogin.ts +287 -0
- package/src/models/Transaction.ts +247 -0
- package/src/models/Transfer.ts +459 -0
- package/src/models/Wire.ts +405 -0
- package/src/models/Withdrawal.ts +283 -0
- package/src/models/redaction.ts +22 -0
- package/src/sca/ScaClient.ts +289 -0
- package/src/securekey/InMemorySecureKey.ts +138 -0
- package/src/securekey/NativeSecureKey.ts +179 -0
- package/src/securekey/NativeSecureKeyBridge.ts +109 -0
- package/src/securekey/SecureKey.ts +149 -0
- package/src/securekey/alias.ts +204 -0
- package/src/securekey/ownerAuthKeyResolver.ts +96 -0
- package/src/securekey/resolveNativeBridge.ts +185 -0
- package/src/testing.ts +32 -0
- package/src/transport/DaaTransport.ts +42 -0
- package/src/transport/headers.ts +46 -0
- package/src/validation/requestBody.ts +60 -0
- package/src/validation/uuid.ts +31 -0
- package/src/wire/accountLimitsUsagePayload.ts +182 -0
- package/src/wire/accountPayload.ts +108 -0
- package/src/wire/achPayload.ts +98 -0
- package/src/wire/addressObjectPayload.ts +64 -0
- package/src/wire/daaStatusCodes.ts +69 -0
- package/src/wire/dataEnvelope.ts +80 -0
- package/src/wire/depositPayload.ts +186 -0
- package/src/wire/deviceContextPayload.ts +58 -0
- package/src/wire/deviceRegistrationResultPayload.ts +153 -0
- package/src/wire/errorEnvelope.ts +87 -0
- package/src/wire/fiatAccountPayload.ts +112 -0
- package/src/wire/instant.ts +93 -0
- package/src/wire/jsonNumber.ts +33 -0
- package/src/wire/moneyPayload.ts +55 -0
- package/src/wire/paginationLinks.ts +204 -0
- package/src/wire/payload.ts +146 -0
- package/src/wire/pendingRegistrationPayload.ts +75 -0
- package/src/wire/socialLoginRequestPayload.ts +89 -0
- package/src/wire/transactionPayload.ts +145 -0
- package/src/wire/transferPayload.ts +249 -0
- package/src/wire/wireEnums.ts +74 -0
- package/src/wire/wirePayload.ts +160 -0
- package/src/wire/withdrawalPayload.ts +219 -0
- package/testing.d.ts +19 -0
- package/testing.js +25 -0
|
@@ -0,0 +1,24 @@
|
|
|
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 { NativeSecureKeyBridge } from './NativeSecureKeyBridge';
|
|
19
|
+
import type { OwnerAuthKey, OwnerKeyIdentity, SecureKeyStore } from './SecureKey';
|
|
20
|
+
export declare class NativeSecureKeyStore implements SecureKeyStore {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(bridge: NativeSecureKeyBridge);
|
|
23
|
+
resolveOrCreate(identity: OwnerKeyIdentity): Promise<OwnerAuthKey>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
20
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
21
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
22
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
23
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
+
};
|
|
30
|
+
var _NativeOwnerAuthKey_resolution, _NativeOwnerAuthKey_acknowledging, _NativeOwnerAuthKey_bridge, _NativeOwnerAuthKey_alias, _NativeSecureKeyStore_keys, _NativeSecureKeyStore_bridge;
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.NativeSecureKeyStore = void 0;
|
|
33
|
+
const base64url_1 = require("../crypto/base64url");
|
|
34
|
+
const jwkThumbprint_1 = require("../crypto/jwkThumbprint");
|
|
35
|
+
const errors_1 = require("../errors");
|
|
36
|
+
const alias_1 = require("./alias");
|
|
37
|
+
// Production DAA Owner-key store backed by the platform secure-key module. It
|
|
38
|
+
// holds no key material itself — every operation delegates to the native bridge,
|
|
39
|
+
// which keeps the non-exportable private key behind the OS keystore/enclave.
|
|
40
|
+
//
|
|
41
|
+
// The bridge is injected so this class is unit-testable without native hardware
|
|
42
|
+
// (see src/__test__/nativeSecureKey.test.ts). Production wiring resolves the
|
|
43
|
+
// real native module via resolveNativeBridge().
|
|
44
|
+
//
|
|
45
|
+
// The `'created' | 'existing'` discriminant native returns from resolveOrCreate
|
|
46
|
+
// is retained on the handle rather than discarded, so a caller can tell an
|
|
47
|
+
// AuthKey still awaiting Circle's registration acknowledgement from one that
|
|
48
|
+
// already has it. It is deliberately NOT flattened at this seam.
|
|
49
|
+
// The alias namespaces one key per `{appId, environment, clientEntityId}` —
|
|
50
|
+
// per Owner, not per installation (see secureKeyAlias).
|
|
51
|
+
// The Expo module parses that alias in TypeScript, then constructs native
|
|
52
|
+
// `DaaAuthKeyIdentity` with a durable per-install UUID it owns (app-container
|
|
53
|
+
// file excluded from backup on iOS, app-private no-backup storage on Android;
|
|
54
|
+
// both are deleted on uninstall). Native key tags therefore include the
|
|
55
|
+
// installation UUID.
|
|
56
|
+
// Run a native bridge call, mapping any rejection onto DaaSdkError so raw
|
|
57
|
+
// keystore/enclave text never reaches the caller.
|
|
58
|
+
async function guardNative(op) {
|
|
59
|
+
try {
|
|
60
|
+
return await op();
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
throw (0, errors_1.mapNativeError)(err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Decode a Base64URL value the native module returned and assert its exact byte
|
|
67
|
+
// length — the seam is the last place to enforce the OwnerAuthKey contract
|
|
68
|
+
// before these values reach the wire or pin an Owner key.
|
|
69
|
+
function decodeExact(value, expected, what) {
|
|
70
|
+
let bytes;
|
|
71
|
+
try {
|
|
72
|
+
bytes = (0, base64url_1.fromBase64Url)(value);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
throw (0, errors_1.contractViolation)(`native ${what} is not valid Base64URL`);
|
|
76
|
+
}
|
|
77
|
+
if (bytes.length !== expected) {
|
|
78
|
+
throw (0, errors_1.contractViolation)(`native ${what} must be ${expected} bytes; got ${bytes.length}`);
|
|
79
|
+
}
|
|
80
|
+
return bytes;
|
|
81
|
+
}
|
|
82
|
+
// Re-validate the discriminant at the store seam. resolveNativeBridge() already
|
|
83
|
+
// checks it for the production module, but an injected stand-in is untyped at
|
|
84
|
+
// runtime, so a third value must fail closed here too rather than being pinned
|
|
85
|
+
// onto a handle and read back later as if it were meaningful.
|
|
86
|
+
function parseNativeResolution(value) {
|
|
87
|
+
if (value === 'created' || value === 'existing') {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
throw (0, errors_1.contractViolation)('native resolveOrCreate must return created or existing');
|
|
91
|
+
}
|
|
92
|
+
class NativeOwnerAuthKey {
|
|
93
|
+
constructor(bridge, alias, resolution) {
|
|
94
|
+
_NativeOwnerAuthKey_resolution.set(this, void 0);
|
|
95
|
+
_NativeOwnerAuthKey_acknowledging.set(this, null);
|
|
96
|
+
_NativeOwnerAuthKey_bridge.set(this, void 0);
|
|
97
|
+
_NativeOwnerAuthKey_alias.set(this, void 0);
|
|
98
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_bridge, bridge, "f");
|
|
99
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_alias, alias, "f");
|
|
100
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_resolution, resolution, "f");
|
|
101
|
+
}
|
|
102
|
+
resolution() {
|
|
103
|
+
return __classPrivateFieldGet(this, _NativeOwnerAuthKey_resolution, "f");
|
|
104
|
+
}
|
|
105
|
+
async acknowledgeRegistration() {
|
|
106
|
+
if (__classPrivateFieldGet(this, _NativeOwnerAuthKey_resolution, "f") === 'existing') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (__classPrivateFieldGet(this, _NativeOwnerAuthKey_acknowledging, "f") === null) {
|
|
110
|
+
// De-duplicate concurrent callers on one handle to a single native round
|
|
111
|
+
// trip, the same way NativeSecureKeyStore.resolveOrCreate does. The
|
|
112
|
+
// `existing` check above cannot do it alone: it is synchronous, so two
|
|
113
|
+
// callers that do not await between them both observe `created`.
|
|
114
|
+
//
|
|
115
|
+
// Cleared on failure so a transient native error stays retryable and is
|
|
116
|
+
// not memoized as a permanently poisoned acknowledgement.
|
|
117
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_acknowledging, guardNative(() => __classPrivateFieldGet(this, _NativeOwnerAuthKey_bridge, "f").acknowledgeRegistration(__classPrivateFieldGet(this, _NativeOwnerAuthKey_alias, "f")))
|
|
118
|
+
.then(() => {
|
|
119
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_resolution, 'existing', "f");
|
|
120
|
+
})
|
|
121
|
+
.catch((err) => {
|
|
122
|
+
__classPrivateFieldSet(this, _NativeOwnerAuthKey_acknowledging, null, "f");
|
|
123
|
+
throw err;
|
|
124
|
+
}), "f");
|
|
125
|
+
}
|
|
126
|
+
return __classPrivateFieldGet(this, _NativeOwnerAuthKey_acknowledging, "f");
|
|
127
|
+
}
|
|
128
|
+
async publicKeySpkiBase64Url() {
|
|
129
|
+
const spki = await guardNative(() => __classPrivateFieldGet(this, _NativeOwnerAuthKey_bridge, "f").publicKeySpkiBase64Url(__classPrivateFieldGet(this, _NativeOwnerAuthKey_alias, "f")));
|
|
130
|
+
decodeExact(spki, 91, 'public key (P-256 SPKI)'); // P-256 SPKI is exactly 91 DER bytes
|
|
131
|
+
return spki;
|
|
132
|
+
}
|
|
133
|
+
async thumbprint() {
|
|
134
|
+
// Derived in TS from the (length-checked) SPKI — one RFC 7638 implementation
|
|
135
|
+
// shared with the in-memory store; no native thumbprint to drift.
|
|
136
|
+
const spki = await this.publicKeySpkiBase64Url();
|
|
137
|
+
return (0, jwkThumbprint_1.p256JwkThumbprint)((0, base64url_1.fromBase64Url)(spki));
|
|
138
|
+
}
|
|
139
|
+
async signExactBytes(message) {
|
|
140
|
+
const raw = await guardNative(() => __classPrivateFieldGet(this, _NativeOwnerAuthKey_bridge, "f").sign(__classPrivateFieldGet(this, _NativeOwnerAuthKey_alias, "f"), (0, base64url_1.toBase64Url)(message)));
|
|
141
|
+
// A native module that forgets DER -> R||S returns ~70 bytes that decode
|
|
142
|
+
// cleanly; the exact-length check catches it here, before the wire.
|
|
143
|
+
return decodeExact(raw, 64, 'signature (JOSE R||S; convert DER ECDSA to R||S)');
|
|
144
|
+
}
|
|
145
|
+
async signRegistrationDeviceAuthorization(message) {
|
|
146
|
+
// A DIFFERENT bridge call from signExactBytes/sign above — see
|
|
147
|
+
// SecureKey.ts and NativeSecureKeyBridge.ts for why the registration
|
|
148
|
+
// device proof cannot share the post-activation seam.
|
|
149
|
+
const raw = await guardNative(() => __classPrivateFieldGet(this, _NativeOwnerAuthKey_bridge, "f").signRegistrationDeviceAuthorization(__classPrivateFieldGet(this, _NativeOwnerAuthKey_alias, "f"), (0, base64url_1.toBase64Url)(message)));
|
|
150
|
+
return decodeExact(raw, 64, 'registration signature (JOSE R||S; convert DER ECDSA to R||S)');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
_NativeOwnerAuthKey_resolution = new WeakMap(), _NativeOwnerAuthKey_acknowledging = new WeakMap(), _NativeOwnerAuthKey_bridge = new WeakMap(), _NativeOwnerAuthKey_alias = new WeakMap();
|
|
154
|
+
class NativeSecureKeyStore {
|
|
155
|
+
constructor(bridge) {
|
|
156
|
+
_NativeSecureKeyStore_keys.set(this, new Map());
|
|
157
|
+
_NativeSecureKeyStore_bridge.set(this, void 0);
|
|
158
|
+
__classPrivateFieldSet(this, _NativeSecureKeyStore_bridge, bridge, "f");
|
|
159
|
+
}
|
|
160
|
+
async resolveOrCreate(identity) {
|
|
161
|
+
const alias = (0, alias_1.secureKeyAlias)(identity);
|
|
162
|
+
let existing = __classPrivateFieldGet(this, _NativeSecureKeyStore_keys, "f").get(alias);
|
|
163
|
+
if (!existing) {
|
|
164
|
+
// Evict on failure so a transient native error is not memoized forever;
|
|
165
|
+
// map the native rejection onto DaaSdkError.
|
|
166
|
+
existing = guardNative(() => __classPrivateFieldGet(this, _NativeSecureKeyStore_bridge, "f").resolveOrCreate(alias))
|
|
167
|
+
.then((raw) => new NativeOwnerAuthKey(__classPrivateFieldGet(this, _NativeSecureKeyStore_bridge, "f"), alias, parseNativeResolution(raw)))
|
|
168
|
+
.catch((err) => {
|
|
169
|
+
__classPrivateFieldGet(this, _NativeSecureKeyStore_keys, "f").delete(alias);
|
|
170
|
+
throw err;
|
|
171
|
+
});
|
|
172
|
+
__classPrivateFieldGet(this, _NativeSecureKeyStore_keys, "f").set(alias, existing);
|
|
173
|
+
}
|
|
174
|
+
return existing;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.NativeSecureKeyStore = NativeSecureKeyStore;
|
|
178
|
+
_NativeSecureKeyStore_keys = new WeakMap(), _NativeSecureKeyStore_bridge = new WeakMap();
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { AuthKeyResolution } from './SecureKey';
|
|
19
|
+
export type NativeAuthKeyResolution = AuthKeyResolution;
|
|
20
|
+
export interface NativeSecureKeyBridge {
|
|
21
|
+
/**
|
|
22
|
+
* Ensure a non-exportable P-256 key exists for `alias`, creating it only when
|
|
23
|
+
* absent. Idempotent.
|
|
24
|
+
*
|
|
25
|
+
* Returns the native SDKs' resolution discriminant, which is about
|
|
26
|
+
* REGISTRATION state, not merely whether this call minted the key:
|
|
27
|
+
* `'created'` when the key was just minted OR when an existing key carries no
|
|
28
|
+
* durable registration acknowledgement; `'existing'` only for a key Circle is
|
|
29
|
+
* durably recorded as having registered. `acknowledgeRegistration` is what
|
|
30
|
+
* moves a key from the former to the latter.
|
|
31
|
+
*/
|
|
32
|
+
resolveOrCreate(alias: string): Promise<NativeAuthKeyResolution>;
|
|
33
|
+
/** Unpadded Base64URL DER SubjectPublicKeyInfo of the public key. */
|
|
34
|
+
publicKeySpkiBase64Url(alias: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Persist that Circle registered the public key for `alias`. Idempotent —
|
|
37
|
+
* native no-ops when the key is already acknowledged. After it succeeds,
|
|
38
|
+
* later `resolveOrCreate` calls return `'existing'`.
|
|
39
|
+
*/
|
|
40
|
+
acknowledgeRegistration(alias: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* ES256 signature over the exact message bytes.
|
|
43
|
+
*
|
|
44
|
+
* Production `resolveNativeBridge()` sends those bytes to Expo
|
|
45
|
+
* `signDeviceAuthorization` (native `DaaSecureKey.signDeviceAuthorization`
|
|
46
|
+
* + `DaaDeviceAuthorizationSigningInput`). There is no native generic
|
|
47
|
+
* `sign(bytes)` Expo method. Compact JWS construction lives in
|
|
48
|
+
* `auth/deviceAuthorization.ts` and signs through `OwnerAuthKey.signExactBytes`.
|
|
49
|
+
* Native validates the compact signing input and signs that same slice.
|
|
50
|
+
* The header carries the published `typ` as-is.
|
|
51
|
+
*
|
|
52
|
+
* Injectable test stand-ins may still implement this for NativeSecureKeyStore
|
|
53
|
+
* unit tests (including arbitrary bytes the native validator would reject).
|
|
54
|
+
*
|
|
55
|
+
* @param messageBase64Url unpadded Base64URL of the exact bytes to sign.
|
|
56
|
+
* @returns unpadded Base64URL of the 64-byte JOSE `R || S` signature.
|
|
57
|
+
*/
|
|
58
|
+
sign(alias: string, messageBase64Url: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* ES256 signature over the exact Device Registration Complete device-proof
|
|
61
|
+
* signing input.
|
|
62
|
+
*
|
|
63
|
+
* A DISTINCT method from {@link sign}, not an overload or a shared code
|
|
64
|
+
* path: production `resolveNativeBridge()` sends these bytes to Expo
|
|
65
|
+
* `signRegistrationDeviceAuthorization` (native
|
|
66
|
+
* `DaaSecureKey.signRegistrationDeviceAuthorization` +
|
|
67
|
+
* `DaaRegistrationAuthorizationSigningInput`), which is a different native
|
|
68
|
+
* function with a different validator than `signDeviceAuthorization` +
|
|
69
|
+
* `DaaDeviceAuthorizationSigningInput` behind {@link sign}. The registration
|
|
70
|
+
* profile is built in `auth/registrationAuthorization.ts` and signs through
|
|
71
|
+
* `OwnerAuthKey.signRegistrationDeviceAuthorization`. Native validates the
|
|
72
|
+
* compact signing input and signs that same slice; it does not require a
|
|
73
|
+
* durably acknowledged key, because Complete runs before
|
|
74
|
+
* `acknowledgeRegistration`.
|
|
75
|
+
*
|
|
76
|
+
* Injectable test stand-ins may still implement this for NativeSecureKeyStore
|
|
77
|
+
* unit tests (including arbitrary bytes the native validator would reject).
|
|
78
|
+
*
|
|
79
|
+
* @param messageBase64Url unpadded Base64URL of the exact bytes to sign.
|
|
80
|
+
* @returns unpadded Base64URL of the 64-byte JOSE `R || S` signature.
|
|
81
|
+
*/
|
|
82
|
+
signRegistrationDeviceAuthorization(alias: string, messageBase64Url: string): Promise<string>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 });
|
|
@@ -0,0 +1,137 @@
|
|
|
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 { DaaEnvironment } from '../config';
|
|
19
|
+
/**
|
|
20
|
+
* The consumer's application-level identity: `appId` and `environment`, known
|
|
21
|
+
* at `DaaClient`/`AuthClient` construction, before any Owner is known.
|
|
22
|
+
*
|
|
23
|
+
* Combined with a per-Owner `clientEntityId` — available only after the
|
|
24
|
+
* Social Session response — to form the full {@link OwnerKeyIdentity} the
|
|
25
|
+
* secure-key store resolves. Kept as its own type so the two are
|
|
26
|
+
* never silently conflated: an app-level identity cannot select an AuthKey by
|
|
27
|
+
* itself, and code that only has one cannot pretend otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export type AppKeyIdentity = Readonly<{
|
|
30
|
+
appId: string;
|
|
31
|
+
environment: DaaEnvironment;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Identity that namespaces the installation AuthKey: one non-exportable
|
|
35
|
+
* P-256/ES256 key per `{appId, environment, clientEntityId (Owner),
|
|
36
|
+
* installation}`.
|
|
37
|
+
*
|
|
38
|
+
* `clientEntityId` must be the SERVER-CONFIRMED value the Social Session
|
|
39
|
+
* response echoed back — never a caller-supplied value the SDK has not
|
|
40
|
+
* validated. See `models/PreparedSocialLogin.ts#completeSocialSession`.
|
|
41
|
+
*
|
|
42
|
+
* The raw value never reaches native or the alias in the clear: `alias.ts`
|
|
43
|
+
* only ever folds it into `deriveKeyScope`'s SHA-256 digest.
|
|
44
|
+
*/
|
|
45
|
+
export type OwnerKeyIdentity = AppKeyIdentity & Readonly<{
|
|
46
|
+
clientEntityId: string;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Result of resolving the installation AuthKey. Same name and same two cases as
|
|
50
|
+
* the native SDKs' `AuthKeyResolution` (`daa-ios-sdk`, `daa-android-sdk`), so
|
|
51
|
+
* the discriminant is not renamed or re-interpreted as it crosses the bridge.
|
|
52
|
+
*
|
|
53
|
+
* This is about REGISTRATION state, not about which call minted the key:
|
|
54
|
+
*
|
|
55
|
+
* - `created` — the key was just minted, OR a key already exists but carries no
|
|
56
|
+
* durable registration acknowledgement. Per the native SDK contract, passcode
|
|
57
|
+
* removal, Keychain reset, device restore, or a crash before acknowledgement
|
|
58
|
+
* all resolve to `created` rather than silently presenting an unregistered
|
|
59
|
+
* key as registered.
|
|
60
|
+
* - `existing` — returned only for a key with a durable acknowledgement, i.e.
|
|
61
|
+
* after {@link OwnerAuthKey.acknowledgeRegistration} has succeeded.
|
|
62
|
+
*/
|
|
63
|
+
export type AuthKeyResolution = 'created' | 'existing';
|
|
64
|
+
/**
|
|
65
|
+
* The DAA Owner AuthKey.
|
|
66
|
+
*
|
|
67
|
+
* The private key never leaves the secure key handle. There is deliberately NO
|
|
68
|
+
* generic `sign(bytes)` at the SDK surface — signing is reachable only through
|
|
69
|
+
* this DAA-specific API, for defined DAA operations (login completion, protected
|
|
70
|
+
* writes, signed context refresh). See SECURITY.md.
|
|
71
|
+
*
|
|
72
|
+
* **Not the ephemeral registration-flow key.** The login contract has two
|
|
73
|
+
* P-256 keys, and this is the durable, namespaced, enclave-held one. The other —
|
|
74
|
+
* per login attempt, anonymous, process memory only, exported at Prepare — is
|
|
75
|
+
* `auth/RegistrationFlowKey.ts`, which never comes from this store and carries a
|
|
76
|
+
* comparison table for the difference.
|
|
77
|
+
*/
|
|
78
|
+
export interface OwnerAuthKey {
|
|
79
|
+
/** Unpadded Base64URL DER SubjectPublicKeyInfo of the public key. */
|
|
80
|
+
publicKeySpkiBase64Url(): Promise<string>;
|
|
81
|
+
/** RFC 7638 JWK thumbprint (`jkt`) of the P-256 public key. */
|
|
82
|
+
thumbprint(): Promise<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Registration state of this handle: `created` while Circle's acknowledgement
|
|
85
|
+
* is still outstanding, `existing` once it is durably recorded. Read from the
|
|
86
|
+
* value the store observed when it resolved the key, and refreshed locally by
|
|
87
|
+
* {@link acknowledgeRegistration}.
|
|
88
|
+
*/
|
|
89
|
+
resolution(): AuthKeyResolution;
|
|
90
|
+
/**
|
|
91
|
+
* Persist that Circle registered this public key, moving the handle from
|
|
92
|
+
* `created` to `existing`. Idempotent: a no-op once the handle is `existing`.
|
|
93
|
+
*
|
|
94
|
+
* Per the native SDK contract the caller invokes this only AFTER Circle has
|
|
95
|
+
* successfully registered the exported SPKI. Device Registration Complete
|
|
96
|
+
* calls it on an `ACTIVE` result. `RECOVERY_PENDING` must not.
|
|
97
|
+
*/
|
|
98
|
+
acknowledgeRegistration(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Produce an ES256 signature (JOSE `R || S`, 64 bytes) over the exact message
|
|
101
|
+
* bytes. The caller passes the already-serialized signing input; this method
|
|
102
|
+
* does not reserialize or canonicalize.
|
|
103
|
+
*
|
|
104
|
+
* This seam does NOT gate on {@link resolution}. Registered-device
|
|
105
|
+
* authorization (`auth/deviceAuthorization.ts`) requires `existing` before it
|
|
106
|
+
* calls this. Production `NativeSecureKeyStore` reaches native
|
|
107
|
+
* `signDeviceAuthorization`, which rejects with `authKeyRegistrationRequired`
|
|
108
|
+
* until acknowledgement succeeds (except native-allowed login completion).
|
|
109
|
+
* There is no public generic `sign(bytes)`.
|
|
110
|
+
*
|
|
111
|
+
* **Post-activation only.** Do not call this for the Device Registration
|
|
112
|
+
* Complete device proof — see {@link signRegistrationDeviceAuthorization}.
|
|
113
|
+
*/
|
|
114
|
+
signExactBytes(message: Uint8Array): Promise<Uint8Array>;
|
|
115
|
+
/**
|
|
116
|
+
* Produce an ES256 signature (JOSE `R || S`, 64 bytes) over the exact
|
|
117
|
+
* Device Registration Complete device-proof signing input
|
|
118
|
+
* (`auth/registrationAuthorization.ts`'s `X-Device-Authorization`, the
|
|
119
|
+
* registration profile's claim/header shape, not the post-activation one
|
|
120
|
+
* of the same header name).
|
|
121
|
+
*
|
|
122
|
+
* A DIFFERENT native seam from {@link signExactBytes}, on purpose: this key
|
|
123
|
+
* has typically not been acknowledged yet (Complete runs before
|
|
124
|
+
* `acknowledgeRegistration`), and the registration profile's claim set and
|
|
125
|
+
* embedded-JWK header are validated by native's registration validator, not
|
|
126
|
+
* `DaaDeviceAuthorizationSigningInput`. Production `NativeSecureKeyStore`
|
|
127
|
+
* reaches native `signRegistrationDeviceAuthorization`. Routing this proof
|
|
128
|
+
* through `signExactBytes` instead would sign valid bytes against the wrong
|
|
129
|
+
* native validator and fail on a real device even though it looks correct
|
|
130
|
+
* in this SDK's own JWS construction.
|
|
131
|
+
*/
|
|
132
|
+
signRegistrationDeviceAuthorization(message: Uint8Array): Promise<Uint8Array>;
|
|
133
|
+
}
|
|
134
|
+
export interface SecureKeyStore {
|
|
135
|
+
/** Resolve the installation AuthKey, creating it only when absent. */
|
|
136
|
+
resolveOrCreate(identity: OwnerKeyIdentity): Promise<OwnerAuthKey>;
|
|
137
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 });
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { DaaEnvironment } from '../config';
|
|
19
|
+
import type { OwnerKeyIdentity } from './SecureKey';
|
|
20
|
+
/**
|
|
21
|
+
* The per-Owner key-scope component: unpadded Base64URL of the
|
|
22
|
+
* first 128 bits of SHA-256 over `appId`, `environment`, and `clientEntityId`.
|
|
23
|
+
*
|
|
24
|
+
* The preimage deliberately includes `appId` and `environment`, not
|
|
25
|
+
* `clientEntityId` alone, so the digest cannot be correlated across
|
|
26
|
+
* applications or environments for the same Owner.
|
|
27
|
+
*
|
|
28
|
+
* `appId`, `environment`, and `clientEntityId` are joined with a NUL (`\0`)
|
|
29
|
+
* separator. NUL cannot appear in any of the three — `APP_ID_CHARSET` excludes
|
|
30
|
+
* control characters, `environment` is one of the fixed `DAA_ENVIRONMENTS`
|
|
31
|
+
* strings, and `clientEntityId` is validated as a hyphenated UUID — so the
|
|
32
|
+
* join cannot map two different triples onto the same preimage bytes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function deriveKeyScope(identity: OwnerKeyIdentity): string;
|
|
35
|
+
/**
|
|
36
|
+
* What actually reaches the native module's `appId` parameter once
|
|
37
|
+
* `parseSecureKeyAlias` recovers it: the consumer's configured `appId`
|
|
38
|
+
* composed with the derived per-Owner {@link deriveKeyScope} digest — NOT
|
|
39
|
+
* `OwnerKeyIdentity.appId` alone.
|
|
40
|
+
*
|
|
41
|
+
* Kept as its own type, rather than reusing or widening `OwnerKeyIdentity`,
|
|
42
|
+
* so the consumer's raw `appId` and the opaque scoped value native receives
|
|
43
|
+
* are never silently conflated. `environment` is unchanged, since
|
|
44
|
+
* it is not namespaced by Owner.
|
|
45
|
+
*/
|
|
46
|
+
export type NativeKeyIdentity = Readonly<{
|
|
47
|
+
appId: string;
|
|
48
|
+
environment: DaaEnvironment;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Build the RN secure-key alias: `{appId}.{keyScope}.{environment}`, where
|
|
52
|
+
* `keyScope` is {@link deriveKeyScope}'s digest of `identity`.
|
|
53
|
+
*
|
|
54
|
+
* `keyScope` is composed with `appId` in the slot native validates and stores
|
|
55
|
+
* against — the derived scope, not `identity.clientEntityId` and not
|
|
56
|
+
* `identity.appId` by itself, is what reaches the native module (see
|
|
57
|
+
* {@link NativeKeyIdentity}). Two different Owners (`clientEntityId`) on the
|
|
58
|
+
* same `{appId, environment}` therefore resolve to two different aliases, and
|
|
59
|
+
* so to two different native keys. A returning Owner reproduces the same
|
|
60
|
+
* digest and so the same alias, and therefore resolves the SAME native key.
|
|
61
|
+
*/
|
|
62
|
+
export declare function secureKeyAlias(identity: OwnerKeyIdentity): string;
|
|
63
|
+
/**
|
|
64
|
+
* Inverse of `secureKeyAlias`'s environment split — NOT a full inverse of
|
|
65
|
+
* `secureKeyAlias`, because {@link deriveKeyScope} is one-way. Splits from the
|
|
66
|
+
* right so the composed `{appId}.{keyScope}` prefix may itself contain dots
|
|
67
|
+
* (an `appId` always could). The Expo module then constructs native
|
|
68
|
+
* `DaaAuthKeyIdentity` from these fields plus a per-install UUID the native
|
|
69
|
+
* module owns.
|
|
70
|
+
*
|
|
71
|
+
* Returns {@link NativeKeyIdentity}, not `OwnerKeyIdentity`: what this
|
|
72
|
+
* recovers is the value native's `appId` parameter needs — the composed
|
|
73
|
+
* scope — not the consumer's original `appId` and not the `clientEntityId`
|
|
74
|
+
* that fed into it. That information is exactly what the hash discards, by
|
|
75
|
+
* design.
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseSecureKeyAlias(alias: string): NativeKeyIdentity;
|
|
78
|
+
/**
|
|
79
|
+
* Validates the consumer-supplied `appId`, before the per-Owner scope is
|
|
80
|
+
* folded in — so the cap is MAX_APP_ID_LENGTH, not native's slot size.
|
|
81
|
+
*
|
|
82
|
+
* Exported for `DaaClient`'s constructor, so an `appId` no key can be stored
|
|
83
|
+
* under is refused before any request is sent, not on the first key
|
|
84
|
+
* resolution — which comes after Social Session has already bound the end
|
|
85
|
+
* user. `secureKeyAlias` still checks it, because a store can be reached
|
|
86
|
+
* without a `DaaClient`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function assertAppId(appId: string): void;
|