@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,175 @@
|
|
|
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.deriveKeyScope = deriveKeyScope;
|
|
21
|
+
exports.secureKeyAlias = secureKeyAlias;
|
|
22
|
+
exports.parseSecureKeyAlias = parseSecureKeyAlias;
|
|
23
|
+
exports.assertAppId = assertAppId;
|
|
24
|
+
const config_1 = require("../config");
|
|
25
|
+
const base64url_1 = require("../crypto/base64url");
|
|
26
|
+
const sha256_1 = require("../crypto/sha256");
|
|
27
|
+
const errors_1 = require("../errors");
|
|
28
|
+
const uuid_1 = require("../validation/uuid");
|
|
29
|
+
// The installation key namespace. This value is interpolated into an OS keystore
|
|
30
|
+
// identifier (iOS `kSecAttrApplicationTag`, Android KeyStore alias), so ALL
|
|
31
|
+
// THREE inputs are validated — it is a custody-key namespace, not free text,
|
|
32
|
+
// and a store can be constructed without going through DaaClient's checks.
|
|
33
|
+
//
|
|
34
|
+
// Validating `environment` against the allow-list is what keeps the alias
|
|
35
|
+
// injective on that axis: no allowed environment contains `.`, so splitting
|
|
36
|
+
// from the right always recovers it (see `parseSecureKeyAlias`).
|
|
37
|
+
//
|
|
38
|
+
// The per-Owner component is a SHA-256 digest, never the raw
|
|
39
|
+
// `clientEntityId` — see `deriveKeyScope`. Hashing also keeps a
|
|
40
|
+
// string-concatenation collision out of the `clientEntityId` axis: recovering
|
|
41
|
+
// two different `(appId, environment, clientEntityId)` triples from one alias
|
|
42
|
+
// would require a SHA-256 preimage or collision, not a parsing ambiguity.
|
|
43
|
+
const APP_ID_CHARSET = /^[A-Za-z0-9._-]+$/;
|
|
44
|
+
// 128 bits of digest is enough collision resistance for a per-installation,
|
|
45
|
+
// per-Owner namespace while leaving room in native's 64-character appId slot
|
|
46
|
+
// for a real-world appId. Base64URL length is computed rather than hardcoded
|
|
47
|
+
// so it can never drift from KEY_SCOPE_DIGEST_BYTES.
|
|
48
|
+
const KEY_SCOPE_DIGEST_BYTES = 16;
|
|
49
|
+
const KEY_SCOPE_LENGTH = Math.ceil((KEY_SCOPE_DIGEST_BYTES * 8) / 6); // 22
|
|
50
|
+
// Native's hard cap on the appId slot (`isValidNamespace` in daa-ios-sdk's
|
|
51
|
+
// DaaSecureKey.swift: `[A-Za-z0-9._-]{1,64}`). The value that actually reaches
|
|
52
|
+
// it is `${appId}.${keyScope}` (see `secureKeyAlias`), so this cap applies to
|
|
53
|
+
// the COMPOSED value, and only `parseSecureKeyAlias` — which recovers that
|
|
54
|
+
// composed value — validates against it.
|
|
55
|
+
const MAX_NATIVE_APP_ID_LENGTH = 64;
|
|
56
|
+
// What a consumer may actually configure as `appId`: native's slot minus the
|
|
57
|
+
// per-Owner scope and its separator. Derived from the two constants above
|
|
58
|
+
// rather than written as 41, so the limit enforced at the door can never drift
|
|
59
|
+
// from the composed value's real budget.
|
|
60
|
+
//
|
|
61
|
+
// Enforcing this in `assertAppId` is what keeps the two checks from
|
|
62
|
+
// disagreeing: an over-long appId is rejected up front, naming the limit the
|
|
63
|
+
// consumer controls, instead of passing validation and failing later during
|
|
64
|
+
// key resolution with a budget the caller never saw.
|
|
65
|
+
const MAX_APP_ID_LENGTH = MAX_NATIVE_APP_ID_LENGTH - 1 - KEY_SCOPE_LENGTH; // 41
|
|
66
|
+
/**
|
|
67
|
+
* The per-Owner key-scope component: unpadded Base64URL of the
|
|
68
|
+
* first 128 bits of SHA-256 over `appId`, `environment`, and `clientEntityId`.
|
|
69
|
+
*
|
|
70
|
+
* The preimage deliberately includes `appId` and `environment`, not
|
|
71
|
+
* `clientEntityId` alone, so the digest cannot be correlated across
|
|
72
|
+
* applications or environments for the same Owner.
|
|
73
|
+
*
|
|
74
|
+
* `appId`, `environment`, and `clientEntityId` are joined with a NUL (`\0`)
|
|
75
|
+
* separator. NUL cannot appear in any of the three — `APP_ID_CHARSET` excludes
|
|
76
|
+
* control characters, `environment` is one of the fixed `DAA_ENVIRONMENTS`
|
|
77
|
+
* strings, and `clientEntityId` is validated as a hyphenated UUID — so the
|
|
78
|
+
* join cannot map two different triples onto the same preimage bytes.
|
|
79
|
+
*/
|
|
80
|
+
function deriveKeyScope(identity) {
|
|
81
|
+
const preimage = `${identity.appId}\u0000${identity.environment}\u0000${identity.clientEntityId}`;
|
|
82
|
+
const digest = (0, sha256_1.sha256)(new TextEncoder().encode(preimage));
|
|
83
|
+
return (0, base64url_1.toBase64Url)(digest.subarray(0, KEY_SCOPE_DIGEST_BYTES));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build the RN secure-key alias: `{appId}.{keyScope}.{environment}`, where
|
|
87
|
+
* `keyScope` is {@link deriveKeyScope}'s digest of `identity`.
|
|
88
|
+
*
|
|
89
|
+
* `keyScope` is composed with `appId` in the slot native validates and stores
|
|
90
|
+
* against — the derived scope, not `identity.clientEntityId` and not
|
|
91
|
+
* `identity.appId` by itself, is what reaches the native module (see
|
|
92
|
+
* {@link NativeKeyIdentity}). Two different Owners (`clientEntityId`) on the
|
|
93
|
+
* same `{appId, environment}` therefore resolve to two different aliases, and
|
|
94
|
+
* so to two different native keys. A returning Owner reproduces the same
|
|
95
|
+
* digest and so the same alias, and therefore resolves the SAME native key.
|
|
96
|
+
*/
|
|
97
|
+
function secureKeyAlias(identity) {
|
|
98
|
+
assertAppId(identity.appId);
|
|
99
|
+
const environment = parseEnvironment(identity.environment);
|
|
100
|
+
assertClientEntityId(identity.clientEntityId);
|
|
101
|
+
const keyScope = deriveKeyScope(identity);
|
|
102
|
+
// No length check is needed here: `assertAppId` caps `appId` at
|
|
103
|
+
// MAX_APP_ID_LENGTH, which is defined as exactly the room left once the
|
|
104
|
+
// separator and the fixed-width `keyScope` are accounted for, so the
|
|
105
|
+
// composed value cannot exceed MAX_NATIVE_APP_ID_LENGTH.
|
|
106
|
+
const nativeAppId = `${identity.appId}.${keyScope}`;
|
|
107
|
+
return `${nativeAppId}.${environment}`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Inverse of `secureKeyAlias`'s environment split — NOT a full inverse of
|
|
111
|
+
* `secureKeyAlias`, because {@link deriveKeyScope} is one-way. Splits from the
|
|
112
|
+
* right so the composed `{appId}.{keyScope}` prefix may itself contain dots
|
|
113
|
+
* (an `appId` always could). The Expo module then constructs native
|
|
114
|
+
* `DaaAuthKeyIdentity` from these fields plus a per-install UUID the native
|
|
115
|
+
* module owns.
|
|
116
|
+
*
|
|
117
|
+
* Returns {@link NativeKeyIdentity}, not `OwnerKeyIdentity`: what this
|
|
118
|
+
* recovers is the value native's `appId` parameter needs — the composed
|
|
119
|
+
* scope — not the consumer's original `appId` and not the `clientEntityId`
|
|
120
|
+
* that fed into it. That information is exactly what the hash discards, by
|
|
121
|
+
* design.
|
|
122
|
+
*/
|
|
123
|
+
function parseSecureKeyAlias(alias) {
|
|
124
|
+
const separator = alias.lastIndexOf('.');
|
|
125
|
+
if (separator <= 0 || separator === alias.length - 1) {
|
|
126
|
+
throw (0, errors_1.contractViolation)(`secure-key alias must be {appId}.{environment} (got a ${alias.length}-char value)`);
|
|
127
|
+
}
|
|
128
|
+
const appId = alias.slice(0, separator);
|
|
129
|
+
const environment = parseEnvironment(alias.slice(separator + 1));
|
|
130
|
+
assertNativeAppId(appId);
|
|
131
|
+
return { appId, environment };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Validates the consumer-supplied `appId`, before the per-Owner scope is
|
|
135
|
+
* folded in — so the cap is MAX_APP_ID_LENGTH, not native's slot size.
|
|
136
|
+
*
|
|
137
|
+
* Exported for `DaaClient`'s constructor, so an `appId` no key can be stored
|
|
138
|
+
* under is refused before any request is sent, not on the first key
|
|
139
|
+
* resolution — which comes after Social Session has already bound the end
|
|
140
|
+
* user. `secureKeyAlias` still checks it, because a store can be reached
|
|
141
|
+
* without a `DaaClient`.
|
|
142
|
+
*/
|
|
143
|
+
function assertAppId(appId) {
|
|
144
|
+
assertAppIdWithin(appId, MAX_APP_ID_LENGTH);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Validates the composed `{appId}.{keyScope}` recovered from an alias, which
|
|
148
|
+
* is what native's appId slot actually receives — so the cap here is native's
|
|
149
|
+
* full MAX_NATIVE_APP_ID_LENGTH. Applying assertAppId's tighter consumer cap
|
|
150
|
+
* would reject legitimate aliases, since the scope alone is 22 characters.
|
|
151
|
+
*/
|
|
152
|
+
function assertNativeAppId(nativeAppId) {
|
|
153
|
+
assertAppIdWithin(nativeAppId, MAX_NATIVE_APP_ID_LENGTH);
|
|
154
|
+
}
|
|
155
|
+
function assertAppIdWithin(value, maxLength) {
|
|
156
|
+
// Report only the length, never the (untrusted) value, so it cannot forge log
|
|
157
|
+
// lines when the error surfaces.
|
|
158
|
+
if (!APP_ID_CHARSET.test(value) || value.length > maxLength) {
|
|
159
|
+
throw (0, errors_1.contractViolation)(`appId must match ${String(APP_ID_CHARSET)} and be at most ${maxLength} ` +
|
|
160
|
+
`characters to namespace the secure key (got a ${value.length}-char value)`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function assertClientEntityId(clientEntityId) {
|
|
164
|
+
if (!(0, uuid_1.isUuid)(clientEntityId)) {
|
|
165
|
+
throw (0, errors_1.contractViolation)('clientEntityId must be a UUID to namespace the secure key');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function parseEnvironment(value) {
|
|
169
|
+
for (const environment of config_1.DAA_ENVIRONMENTS) {
|
|
170
|
+
if (environment === value) {
|
|
171
|
+
return environment;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
throw (0, errors_1.contractViolation)(`unknown environment; expected one of ${config_1.DAA_ENVIRONMENTS.join(', ')}`);
|
|
175
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { AppKeyIdentity, OwnerAuthKey, SecureKeyStore } from './SecureKey';
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the installation AuthKey for one already-known Owner.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately a zero-arg function rather than the store itself: a holder can
|
|
23
|
+
* obtain the one key its identity namespaces and nothing else — no alias of
|
|
24
|
+
* its choosing, and no store to resolve a different one from. This is the
|
|
25
|
+
* shape `DaaUserSigning.resolveAuthKey` (`api/signedResource.ts`) needs,
|
|
26
|
+
* because by the time `forUser` builds one it already knows which Owner it is
|
|
27
|
+
* signing for. It is NOT the shape {@link createOwnerAuthKeyResolver} returns
|
|
28
|
+
* — see {@link AppAuthKeyResolver}.
|
|
29
|
+
*/
|
|
30
|
+
export type OwnerAuthKeyResolver = () => Promise<OwnerAuthKey>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the installation AuthKey for a given Owner, by `clientEntityId`.
|
|
33
|
+
*
|
|
34
|
+
* `clientEntityId` is a per-call parameter rather than baked into the
|
|
35
|
+
* resolver at construction: it is not known when `DaaClient`
|
|
36
|
+
* builds this resolver (only the Social Session response names an Owner), and
|
|
37
|
+
* one long-lived `DaaClient` may serve more than one Owner over its lifetime
|
|
38
|
+
* — sign-out, then sign back in as someone else. Each call site binds the
|
|
39
|
+
* `clientEntityId` it already has (Social Session's response for login;
|
|
40
|
+
* `DaaUserContext.clientEntityId` for `forUser`) and, for `forUser`, wraps the
|
|
41
|
+
* result down to an {@link OwnerAuthKeyResolver} before handing it to a
|
|
42
|
+
* resource client — a resource client has no Owner concept of its own.
|
|
43
|
+
*/
|
|
44
|
+
export type AppAuthKeyResolver = (clientEntityId: string) => Promise<OwnerAuthKey>;
|
|
45
|
+
/**
|
|
46
|
+
* Build the resolver for one application identity.
|
|
47
|
+
*
|
|
48
|
+
* @param identity App-level identity (`appId`, `environment`); `null` when
|
|
49
|
+
* the SDK has no application identity to select a key with, which fails
|
|
50
|
+
* closed at the first resolution rather than at construction —
|
|
51
|
+
* `AuthClient` is built for Prepare, and Prepare never touches an
|
|
52
|
+
* AuthKey.
|
|
53
|
+
* @param secureKeys Injected store, which tests substitute. Absent, the native
|
|
54
|
+
* store is constructed on first use and reused.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createOwnerAuthKeyResolver(identity: AppKeyIdentity | null, secureKeys: SecureKeyStore | null): AppAuthKeyResolver;
|
|
@@ -0,0 +1,63 @@
|
|
|
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.createOwnerAuthKeyResolver = createOwnerAuthKeyResolver;
|
|
21
|
+
// Resolving the installation AuthKey by alias, in one place.
|
|
22
|
+
//
|
|
23
|
+
// Two call sites need the same key: the login ceremony selects it after Social
|
|
24
|
+
// Session (`AuthClient`), and the authenticated operations surface signs writes
|
|
25
|
+
// with it (`DaaClient.forUser`). The key is not carried on `DaaUserContext` —
|
|
26
|
+
// that context is a decoded server result, not a handle to enclave-held key
|
|
27
|
+
// material — so `forUser` re-resolves by the same `{appId, environment}` alias
|
|
28
|
+
// login used, together with the SAME context's `clientEntityId`.
|
|
29
|
+
// `DeviceContext.authKeyId` supplies the JWS `kid` alongside it.
|
|
30
|
+
//
|
|
31
|
+
// The lazy `NativeSecureKeyStore` is why this is a factory rather than a free
|
|
32
|
+
// function. Constructing the store requires the Expo `DaaSecureKey` module, and
|
|
33
|
+
// `DaaClient` construction deliberately does not; the store is therefore built
|
|
34
|
+
// on first resolution and then reused, so login and every later signed write
|
|
35
|
+
// share one store — and so share its in-flight `resolveOrCreate` map rather
|
|
36
|
+
// than racing two independent handles for the same alias.
|
|
37
|
+
const errors_1 = require("../errors");
|
|
38
|
+
const NativeSecureKey_1 = require("./NativeSecureKey");
|
|
39
|
+
const resolveNativeBridge_1 = require("./resolveNativeBridge");
|
|
40
|
+
/**
|
|
41
|
+
* Build the resolver for one application identity.
|
|
42
|
+
*
|
|
43
|
+
* @param identity App-level identity (`appId`, `environment`); `null` when
|
|
44
|
+
* the SDK has no application identity to select a key with, which fails
|
|
45
|
+
* closed at the first resolution rather than at construction —
|
|
46
|
+
* `AuthClient` is built for Prepare, and Prepare never touches an
|
|
47
|
+
* AuthKey.
|
|
48
|
+
* @param secureKeys Injected store, which tests substitute. Absent, the native
|
|
49
|
+
* store is constructed on first use and reused.
|
|
50
|
+
*/
|
|
51
|
+
function createOwnerAuthKeyResolver(identity, secureKeys) {
|
|
52
|
+
// The mutable slot the lazily-constructed native store fills. A closure
|
|
53
|
+
// variable rather than a field because the clients holding this resolver are
|
|
54
|
+
// sealed with `Object.freeze`.
|
|
55
|
+
let nativeStore = null;
|
|
56
|
+
return async (clientEntityId) => {
|
|
57
|
+
if (identity === null) {
|
|
58
|
+
throw (0, errors_1.contractViolation)('AuthKey selection requires the DaaClient application identity');
|
|
59
|
+
}
|
|
60
|
+
const store = secureKeys ?? (nativeStore ?? (nativeStore = new NativeSecureKey_1.NativeSecureKeyStore((0, resolveNativeBridge_1.resolveNativeBridge)())));
|
|
61
|
+
return store.resolveOrCreate({ ...identity, clientEntityId });
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { DeviceKeyPolicy } from '../config';
|
|
19
|
+
import type { NativeSecureKeyBridge } from './NativeSecureKeyBridge';
|
|
20
|
+
/**
|
|
21
|
+
* When the Expo `DaaSecureKey` module is loaded, require that its declared
|
|
22
|
+
* policy matches the configured closed set. No-ops when the module is absent
|
|
23
|
+
* (Node / Jest) so Prepare can still construct a client.
|
|
24
|
+
*
|
|
25
|
+
* This is a version-skew guard between the JS and native module, not a live
|
|
26
|
+
* attestation of a specific key's real protection level — see
|
|
27
|
+
* `declaredKeyPolicy` on `DaaSecureKeyNativeModule` above.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertNativeModuleKeyPolicyIfPresent(configured: DeviceKeyPolicy): void;
|
|
30
|
+
export declare function resolveNativeBridge(): NativeSecureKeyBridge;
|
|
@@ -0,0 +1,120 @@
|
|
|
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.assertNativeModuleKeyPolicyIfPresent = assertNativeModuleKeyPolicyIfPresent;
|
|
21
|
+
exports.resolveNativeBridge = resolveNativeBridge;
|
|
22
|
+
const expo_modules_core_1 = require("expo-modules-core");
|
|
23
|
+
const config_1 = require("../config");
|
|
24
|
+
const errors_1 = require("../errors");
|
|
25
|
+
const alias_1 = require("./alias");
|
|
26
|
+
/**
|
|
27
|
+
* When the Expo `DaaSecureKey` module is loaded, require that its declared
|
|
28
|
+
* policy matches the configured closed set. No-ops when the module is absent
|
|
29
|
+
* (Node / Jest) so Prepare can still construct a client.
|
|
30
|
+
*
|
|
31
|
+
* This is a version-skew guard between the JS and native module, not a live
|
|
32
|
+
* attestation of a specific key's real protection level — see
|
|
33
|
+
* `declaredKeyPolicy` on `DaaSecureKeyNativeModule` above.
|
|
34
|
+
*/
|
|
35
|
+
function assertNativeModuleKeyPolicyIfPresent(configured) {
|
|
36
|
+
const native = (0, expo_modules_core_1.requireOptionalNativeModule)('DaaSecureKey');
|
|
37
|
+
if (native === null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
assertNativeDeclaredKeyPolicy(native, configured);
|
|
41
|
+
}
|
|
42
|
+
function assertNativeDeclaredKeyPolicy(native, configured) {
|
|
43
|
+
const query = native.declaredKeyPolicy;
|
|
44
|
+
if (typeof query !== 'function') {
|
|
45
|
+
throw (0, errors_1.contractViolation)('native DaaSecureKey module did not declare a DeviceKeyPolicy');
|
|
46
|
+
}
|
|
47
|
+
const declared = query.call(native);
|
|
48
|
+
if (!(0, config_1.isRecord)(declared) ||
|
|
49
|
+
declared['hardwareBacked'] !== configured.hardwareBacked ||
|
|
50
|
+
declared['userVerification'] !== configured.userVerification) {
|
|
51
|
+
throw (0, errors_1.contractViolation)('native DaaSecureKey declared keyPolicy does not match the configured DeviceKeyPolicy');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Production wiring to the platform native module (Swift under ios/, Kotlin
|
|
55
|
+
// under android/), resolved via expo-modules-core.
|
|
56
|
+
//
|
|
57
|
+
// Node / Jest have no native module: fail closed rather than silently no-op.
|
|
58
|
+
// Tests inject a NativeSecureKeyBridge explicitly.
|
|
59
|
+
function resolveNativeBridge() {
|
|
60
|
+
const native = (0, expo_modules_core_1.requireOptionalNativeModule)('DaaSecureKey');
|
|
61
|
+
if (native === null) {
|
|
62
|
+
throw (0, errors_1.contractViolation)('native DaaSecureKey module is not available. Provide a NativeSecureKeyBridge ' +
|
|
63
|
+
'explicitly, or run inside a React Native app that includes the DaaSecureKey Expo ' +
|
|
64
|
+
'module.');
|
|
65
|
+
}
|
|
66
|
+
assertNativeDeclaredKeyPolicy(native, config_1.DEVICE_KEY_POLICY);
|
|
67
|
+
return wrapNativeModule(native);
|
|
68
|
+
}
|
|
69
|
+
function wrapNativeModule(native) {
|
|
70
|
+
return {
|
|
71
|
+
async resolveOrCreate(alias) {
|
|
72
|
+
const identity = (0, alias_1.parseSecureKeyAlias)(alias);
|
|
73
|
+
const resolution = await native.resolveOrCreate(identity.appId, identity.environment);
|
|
74
|
+
if (resolution === 'created' || resolution === 'existing') {
|
|
75
|
+
return resolution;
|
|
76
|
+
}
|
|
77
|
+
throw (0, errors_1.contractViolation)('native resolveOrCreate returned an unknown resolution');
|
|
78
|
+
},
|
|
79
|
+
async publicKeySpkiBase64Url(alias) {
|
|
80
|
+
const identity = (0, alias_1.parseSecureKeyAlias)(alias);
|
|
81
|
+
return await native.publicKeySpkiBase64Url(identity.appId, identity.environment);
|
|
82
|
+
},
|
|
83
|
+
async acknowledgeRegistration(alias) {
|
|
84
|
+
// Calls the acknowledgeRegistration the Expo module already exposes on
|
|
85
|
+
// both platforms; no parallel native API is introduced. Native owns
|
|
86
|
+
// idempotence and persistence (Data Protection Keychain on iOS,
|
|
87
|
+
// app-private storage on Android).
|
|
88
|
+
const identity = (0, alias_1.parseSecureKeyAlias)(alias);
|
|
89
|
+
await native.acknowledgeRegistration(identity.appId, identity.environment);
|
|
90
|
+
},
|
|
91
|
+
async sign(alias, messageBase64Url) {
|
|
92
|
+
// Typed native signDeviceAuthorization — not a generic sign(bytes) Expo
|
|
93
|
+
// method. `messageBase64Url` is the exact compact-JWS signing input
|
|
94
|
+
// `deviceAuthorization.ts` already constructed. Native wraps those bytes
|
|
95
|
+
// in DaaDeviceAuthorizationSigningInput (validates, does not re-encode)
|
|
96
|
+
// and returns 64-byte JOSE R||S as unpadded Base64URL.
|
|
97
|
+
if (typeof native.signDeviceAuthorization !== 'function') {
|
|
98
|
+
throw (0, errors_1.contractViolation)('native DaaSecureKey.signDeviceAuthorization is required');
|
|
99
|
+
}
|
|
100
|
+
const identity = (0, alias_1.parseSecureKeyAlias)(alias);
|
|
101
|
+
return await native.signDeviceAuthorization(identity.appId, identity.environment, messageBase64Url);
|
|
102
|
+
},
|
|
103
|
+
async signRegistrationDeviceAuthorization(alias, messageBase64Url) {
|
|
104
|
+
// Typed native signRegistrationDeviceAuthorization — the registration
|
|
105
|
+
// counterpart of `sign` above, NOT the same native call. `messageBase64Url`
|
|
106
|
+
// is the exact compact-JWS signing input `registrationAuthorization.ts`
|
|
107
|
+
// already constructed. Native wraps those bytes in
|
|
108
|
+
// DaaRegistrationAuthorizationSigningInput (a different validator from
|
|
109
|
+
// DaaDeviceAuthorizationSigningInput: registration `typ`s, an embedded
|
|
110
|
+
// JWK header, and the 14-claim registration payload) and returns the
|
|
111
|
+
// 64-byte JOSE R||S signature as unpadded Base64URL. Unlike `sign`, this
|
|
112
|
+
// does not require a durably acknowledged key.
|
|
113
|
+
if (typeof native.signRegistrationDeviceAuthorization !== 'function') {
|
|
114
|
+
throw (0, errors_1.contractViolation)('native DaaSecureKey.signRegistrationDeviceAuthorization is required');
|
|
115
|
+
}
|
|
116
|
+
const identity = (0, alias_1.parseSecureKeyAlias)(alias);
|
|
117
|
+
return await native.signRegistrationDeviceAuthorization(identity.appId, identity.environment, messageBase64Url);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export { InMemorySecureKeyStore } from './securekey/InMemorySecureKey';
|
package/build/testing.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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.InMemorySecureKeyStore = void 0;
|
|
21
|
+
// Test-only entry point: the package's `./testing` subpath.
|
|
22
|
+
//
|
|
23
|
+
// Exposes the DAA Owner-key interfaces and a WebCrypto-backed in-memory store so
|
|
24
|
+
// consumers and golden vectors can exercise signing WITHOUT device hardware.
|
|
25
|
+
//
|
|
26
|
+
// NOT for production: the in-memory store holds a P-256 private key in process
|
|
27
|
+
// memory. It fails closed when constructed in a production build.
|
|
28
|
+
//
|
|
29
|
+
// The Owner-key interfaces (OwnerAuthKey / OwnerKeyIdentity / SecureKeyStore)
|
|
30
|
+
// are exported from the main entry (`.`) since they are the contract a
|
|
31
|
+
// production/native store implements. This subpath adds only the concrete
|
|
32
|
+
// test double.
|
|
33
|
+
var InMemorySecureKey_1 = require("./securekey/InMemorySecureKey");
|
|
34
|
+
Object.defineProperty(exports, "InMemorySecureKeyStore", { enumerable: true, get: function () { return InMemorySecureKey_1.InMemorySecureKeyStore; } });
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
export type DaaHttpRequest = Readonly<{
|
|
19
|
+
method: string;
|
|
20
|
+
/** Signed public API path beginning `/v1` — not a consumer-backend route. */
|
|
21
|
+
path: string;
|
|
22
|
+
/** Exact percent-encoded query without the leading `?`, or null. */
|
|
23
|
+
query: string | null;
|
|
24
|
+
headers: Readonly<Record<string, string>>;
|
|
25
|
+
/** Immutable body bytes. The SDK signs and sends this same slice. */
|
|
26
|
+
bodyBytes: Uint8Array | null;
|
|
27
|
+
}>;
|
|
28
|
+
export type DaaHttpResponse = Readonly<{
|
|
29
|
+
status: number;
|
|
30
|
+
headers: Readonly<Record<string, string>>;
|
|
31
|
+
bodyBytes: Uint8Array | null;
|
|
32
|
+
}>;
|
|
33
|
+
export interface DaaTransport {
|
|
34
|
+
send(request: DaaHttpRequest): Promise<DaaHttpResponse>;
|
|
35
|
+
}
|
|
@@ -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,30 @@
|
|
|
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
|
+
* Look a response header up without assuming its casing.
|
|
20
|
+
*
|
|
21
|
+
* HTTP field names are case-insensitive and HTTP/2 mandates lowercase on the
|
|
22
|
+
* wire, so a `fetch`-based transport may surface `x-request-id` where another
|
|
23
|
+
* surfaces `X-Request-Id`. `DaaHttpResponse` deliberately does not normalize —
|
|
24
|
+
* the transport is the consumer's — so the typed client, which is the first thing
|
|
25
|
+
* that reads a response header, owns the lookup.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` for an absent header. Absence is reported as absence rather than
|
|
28
|
+
* as an empty string, which a provider could also legitimately send.
|
|
29
|
+
*/
|
|
30
|
+
export declare function headerValueIgnoringCase(headers: Readonly<Record<string, string>>, name: string): string | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
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.headerValueIgnoringCase = headerValueIgnoringCase;
|
|
21
|
+
/**
|
|
22
|
+
* Look a response header up without assuming its casing.
|
|
23
|
+
*
|
|
24
|
+
* HTTP field names are case-insensitive and HTTP/2 mandates lowercase on the
|
|
25
|
+
* wire, so a `fetch`-based transport may surface `x-request-id` where another
|
|
26
|
+
* surfaces `X-Request-Id`. `DaaHttpResponse` deliberately does not normalize —
|
|
27
|
+
* the transport is the consumer's — so the typed client, which is the first thing
|
|
28
|
+
* that reads a response header, owns the lookup.
|
|
29
|
+
*
|
|
30
|
+
* Returns `null` for an absent header. Absence is reported as absence rather than
|
|
31
|
+
* as an empty string, which a provider could also legitimately send.
|
|
32
|
+
*/
|
|
33
|
+
function headerValueIgnoringCase(headers, name) {
|
|
34
|
+
const exact = headers[name];
|
|
35
|
+
if (exact !== undefined) {
|
|
36
|
+
return exact;
|
|
37
|
+
}
|
|
38
|
+
const wanted = name.toLowerCase();
|
|
39
|
+
for (const key of Object.keys(headers)) {
|
|
40
|
+
if (key.toLowerCase() === wanted) {
|
|
41
|
+
return headers[key] ?? null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/** Refuse anything that is not a plain JSON object, including an array or null. */
|
|
19
|
+
export declare function requireBodyObject(value: unknown, label: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Refuse a property the operation's registry schema does not name.
|
|
22
|
+
*
|
|
23
|
+
* `Object.keys` reports own enumerable string keys, which is exactly the set
|
|
24
|
+
* `JSON.stringify` would serialize — so this checks the properties that would
|
|
25
|
+
* actually reach the wire rather than a structural approximation of them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function requireKnownProperties(value: object, allowed: readonly string[], label: string): void;
|