@circle-fin/daa-react-native-sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DaaReactNativeSdk.podspec +14 -8
- package/README.md +498 -24
- package/android/build.gradle +12 -7
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +1 -18
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +38 -4
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +139 -6
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +50 -1
- package/build/DaaClient.d.ts +183 -3
- package/build/DaaClient.js +296 -12
- package/build/api/AccountsClient.d.ts +3 -0
- package/build/api/AccountsClient.js +3 -0
- package/build/api/AuthClient.d.ts +17 -42
- package/build/api/AuthClient.js +26 -62
- package/build/api/ContractExecutionsClient.d.ts +114 -0
- package/build/api/ContractExecutionsClient.js +462 -0
- package/build/api/DaaUserClient.d.ts +74 -11
- package/build/api/DaaUserClient.js +84 -17
- package/build/api/TransactionsClient.d.ts +1 -1
- package/build/api/TransactionsClient.js +1 -0
- package/build/api/TransfersClient.d.ts +3 -0
- package/build/api/TransfersClient.js +3 -0
- package/build/api/WithdrawalsClient.d.ts +3 -0
- package/build/api/WithdrawalsClient.js +3 -0
- package/build/api/deviceApproval.d.ts +48 -0
- package/build/api/deviceApproval.js +247 -0
- package/build/api/deviceStatus.d.ts +61 -0
- package/build/api/deviceStatus.js +216 -0
- package/build/api/loginFailure.d.ts +10 -2
- package/build/api/loginFailure.js +33 -2
- package/build/api/signedResource.d.ts +49 -2
- package/build/api/signedResource.js +135 -36
- package/build/auth/RegistrationFlowKey.js +1 -1
- package/build/auth/daaRegistrationNative.d.ts +0 -22
- package/build/auth/daaRegistrationNative.js +3 -29
- package/build/auth/deviceAuthorization.d.ts +17 -3
- package/build/auth/deviceAuthorization.js +60 -8
- package/build/auth/registrationAuthorization.d.ts +2 -2
- package/build/auth/registrationAuthorization.js +13 -10
- package/build/config.d.ts +27 -0
- package/build/config.js +15 -0
- package/build/crypto/matchingCode.d.ts +47 -0
- package/build/crypto/matchingCode.js +93 -0
- package/build/errors.d.ts +150 -33
- package/build/errors.js +208 -47
- package/build/index.d.ts +11 -3
- package/build/models/ContractExecution.d.ts +197 -0
- package/build/models/ContractExecution.js +130 -0
- package/build/models/CreateContractExecutionRequest.d.ts +81 -0
- package/build/models/CreateContractExecutionRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +53 -3
- package/build/models/DaaUserContext.js +33 -2
- package/build/models/DeviceStatus.d.ts +69 -0
- package/build/models/DeviceStatus.js +19 -0
- package/build/models/PendingDeviceApproval.d.ts +121 -0
- package/build/models/PendingDeviceApproval.js +208 -0
- package/build/models/PendingDeviceRegistration.d.ts +162 -23
- package/build/models/PendingDeviceRegistration.js +525 -69
- package/build/models/PreparedContractExecution.d.ts +70 -0
- package/build/models/PreparedContractExecution.js +77 -0
- package/build/models/PreparedSocialLogin.d.ts +19 -26
- package/build/models/PreparedSocialLogin.js +32 -15
- package/build/models/Transaction.d.ts +48 -2
- package/build/models/Transaction.js +52 -4
- package/build/models/codeSecrets.d.ts +100 -0
- package/build/models/codeSecrets.js +321 -0
- package/build/securekey/InMemorySecureKey.d.ts +3 -1
- package/build/securekey/InMemorySecureKey.js +47 -6
- package/build/securekey/NativeSecureKey.d.ts +3 -1
- package/build/securekey/NativeSecureKey.js +204 -27
- package/build/securekey/NativeSecureKeyBridge.d.ts +72 -4
- package/build/securekey/SecureKey.d.ts +128 -8
- package/build/securekey/alias.d.ts +9 -0
- package/build/securekey/alias.js +11 -2
- package/build/securekey/ownerAuthKeyResolver.d.ts +26 -9
- package/build/securekey/ownerAuthKeyResolver.js +35 -20
- package/build/securekey/registration.d.ts +19 -0
- package/build/securekey/registration.js +38 -0
- package/build/securekey/resolveNativeBridge.d.ts +3 -0
- package/build/securekey/resolveNativeBridge.js +88 -7
- package/build/transport/headers.d.ts +11 -0
- package/build/transport/headers.js +36 -0
- package/build/wire/contractExecutionPayload.d.ts +24 -0
- package/build/wire/contractExecutionPayload.js +130 -0
- package/build/wire/daaStatusCodes.d.ts +20 -3
- package/build/wire/daaStatusCodes.js +20 -3
- package/build/wire/deviceContextPayload.d.ts +9 -7
- package/build/wire/deviceContextPayload.js +9 -7
- package/build/wire/deviceRegistrationResultPayload.d.ts +55 -10
- package/build/wire/deviceRegistrationResultPayload.js +116 -82
- package/build/wire/deviceStatusPayload.d.ts +20 -0
- package/build/wire/deviceStatusPayload.js +66 -0
- package/build/wire/instant.js +4 -1
- package/build/wire/pendingRegistrationPayload.d.ts +16 -0
- package/build/wire/pendingRegistrationPayload.js +18 -0
- package/build/wire/socialLoginRequestPayload.d.ts +0 -5
- package/build/wire/socialLoginRequestPayload.js +2 -19
- package/build/wire/transactionPayload.d.ts +2 -2
- package/build/wire/transactionPayload.js +27 -4
- package/ios/DaaRegistrationModule.swift +1 -19
- package/ios/DaaSecureKeyExceptions.swift +53 -5
- package/ios/DaaSecureKeyModule.swift +149 -5
- package/ios/InstallationIdentityStore.swift +43 -7
- package/package.json +1 -1
- package/src/DaaClient.ts +353 -15
- package/src/api/AccountsClient.ts +3 -0
- package/src/api/AuthClient.ts +33 -98
- package/src/api/ContractExecutionsClient.ts +527 -0
- package/src/api/DaaUserClient.ts +92 -17
- package/src/api/TransactionsClient.ts +1 -0
- package/src/api/TransfersClient.ts +3 -0
- package/src/api/WithdrawalsClient.ts +3 -0
- package/src/api/deviceApproval.ts +306 -0
- package/src/api/deviceStatus.ts +238 -0
- package/src/api/loginFailure.ts +39 -2
- package/src/api/signedResource.ts +206 -46
- package/src/auth/RegistrationFlowKey.ts +1 -1
- package/src/auth/daaRegistrationNative.ts +4 -49
- package/src/auth/deviceAuthorization.ts +74 -11
- package/src/auth/registrationAuthorization.ts +12 -9
- package/src/config.ts +36 -0
- package/src/crypto/matchingCode.ts +100 -0
- package/src/errors.ts +309 -52
- package/src/index.ts +36 -1
- package/src/models/ContractExecution.ts +250 -0
- package/src/models/CreateContractExecutionRequest.ts +100 -0
- package/src/models/DaaUserContext.ts +59 -3
- package/src/models/DeviceStatus.ts +50 -0
- package/src/models/PendingDeviceApproval.ts +229 -0
- package/src/models/PendingDeviceRegistration.ts +673 -79
- package/src/models/PreparedContractExecution.ts +128 -0
- package/src/models/PreparedSocialLogin.ts +41 -31
- package/src/models/Transaction.ts +77 -2
- package/src/models/codeSecrets.ts +360 -0
- package/src/securekey/InMemorySecureKey.ts +61 -7
- package/src/securekey/NativeSecureKey.ts +234 -25
- package/src/securekey/NativeSecureKeyBridge.ts +84 -4
- package/src/securekey/SecureKey.ts +138 -8
- package/src/securekey/alias.ts +11 -3
- package/src/securekey/ownerAuthKeyResolver.ts +63 -24
- package/src/securekey/registration.ts +40 -0
- package/src/securekey/resolveNativeBridge.ts +167 -9
- package/src/transport/headers.ts +47 -0
- package/src/wire/contractExecutionPayload.ts +152 -0
- package/src/wire/daaStatusCodes.ts +20 -3
- package/src/wire/deviceContextPayload.ts +9 -7
- package/src/wire/deviceRegistrationResultPayload.ts +156 -98
- package/src/wire/deviceStatusPayload.ts +68 -0
- package/src/wire/instant.ts +4 -1
- package/src/wire/pendingRegistrationPayload.ts +44 -1
- package/src/wire/socialLoginRequestPayload.ts +2 -25
- package/src/wire/transactionPayload.ts +40 -4
- package/build/auth/prepareReceipt.d.ts +0 -150
- package/build/auth/prepareReceipt.js +0 -357
- package/build/crypto/es256Jws.d.ts +0 -56
- package/build/crypto/es256Jws.js +0 -196
- package/src/auth/prepareReceipt.ts +0 -522
- package/src/crypto/es256Jws.ts +0 -240
|
@@ -0,0 +1,114 @@
|
|
|
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 { ContractExecution } from '../models/ContractExecution';
|
|
19
|
+
import type { CreateContractExecutionRequest } from '../models/CreateContractExecutionRequest';
|
|
20
|
+
import { PreparedContractExecution, type PersistedContractExecution } from '../models/PreparedContractExecution';
|
|
21
|
+
import type { DaaTransport } from '../transport/DaaTransport';
|
|
22
|
+
import { type DaaUserSigning } from './signedResource';
|
|
23
|
+
/**
|
|
24
|
+
* Owner-authorized contract execution from a self-custody account, plus its
|
|
25
|
+
* read.
|
|
26
|
+
*
|
|
27
|
+
* A create is two steps because a retry must be exact. {@link prepare}
|
|
28
|
+
* validates the request, serializes it **once**, and signs one
|
|
29
|
+
* `X-Device-Authorization` over those bytes. {@link submit} sends that pair,
|
|
30
|
+
* unchanged, and is what to call again after a transport failure, a `5xx`, an
|
|
31
|
+
* unreadable response, or an app restart ({@link restore} rebuilds the pair
|
|
32
|
+
* from what `PreparedContractExecution.toPersisted` stored).
|
|
33
|
+
*
|
|
34
|
+
* There is deliberately no one-call `create`. Its prepared value would not
|
|
35
|
+
* outlive a failed call, so the only retry left to the caller would be a new
|
|
36
|
+
* signature over the same body — a different `jti`, which DAA answers with
|
|
37
|
+
* `409` rather than the stored execution.
|
|
38
|
+
*
|
|
39
|
+
* The Owner authorization is the approval for this operation; there is no
|
|
40
|
+
* separate strong-customer-authentication step on this route.
|
|
41
|
+
*
|
|
42
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
43
|
+
* the `#transport` field makes the type nominal.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ContractExecutionsClient {
|
|
46
|
+
#private;
|
|
47
|
+
/** @internal Constructed only through the internal user-client factory. */
|
|
48
|
+
constructor(transport: DaaTransport, signing: DaaUserSigning);
|
|
49
|
+
/**
|
|
50
|
+
* Read one contract execution. Poll this until the status is `complete` or
|
|
51
|
+
* `failed`; it is the authoritative outcome.
|
|
52
|
+
*
|
|
53
|
+
* @param contractExecutionId The service-assigned UUID. A value that is not
|
|
54
|
+
* UUID-formatted is rejected locally.
|
|
55
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a rejected
|
|
56
|
+
* id or a response the SDK cannot read; `api` for a status other than
|
|
57
|
+
* `200` (an unknown or inaccessible execution is `404`); `transport` if the
|
|
58
|
+
* consumer's transport throws.
|
|
59
|
+
*/
|
|
60
|
+
get(contractExecutionId: string): Promise<ContractExecution>;
|
|
61
|
+
/**
|
|
62
|
+
* Validate, serialize once, and Owner-authorize a contract execution, without
|
|
63
|
+
* sending it.
|
|
64
|
+
*
|
|
65
|
+
* Store the result (see `PreparedContractExecution.toPersisted`) before the
|
|
66
|
+
* first {@link submit} if the app must survive a restart mid-request.
|
|
67
|
+
*
|
|
68
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a request
|
|
69
|
+
* the registry schema or DAA would reject — including a fee, gas, or other
|
|
70
|
+
* unknown property, and an `abiParameters` count that does not match the
|
|
71
|
+
* signature — and for an AuthKey that is not yet registered. Nothing is
|
|
72
|
+
* signed for a rejected request.
|
|
73
|
+
*/
|
|
74
|
+
prepare(request: CreateContractExecutionRequest): Promise<PreparedContractExecution>;
|
|
75
|
+
/**
|
|
76
|
+
* Send a prepared execution exactly as it was authorized.
|
|
77
|
+
*
|
|
78
|
+
* Safe to repeat: every call sends identical bytes and the identical
|
|
79
|
+
* authorization. DAA answers `201` for a new execution and `200` with the
|
|
80
|
+
* stored execution for an exact replay — including a replay after the
|
|
81
|
+
* authorization has expired — and both resolve here. A replay of a request
|
|
82
|
+
* DAA never accepted, once its authorization has expired, is refused; the
|
|
83
|
+
* recovery is a new execution with a new idempotency key, not a retry.
|
|
84
|
+
*
|
|
85
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a prepared
|
|
86
|
+
* value authorized by a different AuthKey than this user client's, for a
|
|
87
|
+
* rejected, expired, or replayed authorization DAA did not accept, and for
|
|
88
|
+
* a response the SDK cannot read — DAA may have accepted that request, so
|
|
89
|
+
* submit the same value again or poll; never prepare it again under a new
|
|
90
|
+
* key; `clock_skew` when DAA refused the authorization because the device
|
|
91
|
+
* clock was more than 60 seconds off when {@link prepare} signed it — DAA
|
|
92
|
+
* did not accept it, and resubmitting sends the same authorization, so
|
|
93
|
+
* correct the device time and treat it like an expired authorization: a
|
|
94
|
+
* new execution with a new idempotency key; `idempotency_conflict` for a `409` with
|
|
95
|
+
* `IDEMPOTENCY_KEY_REUSED`; `api` for any other status (retryable for `429`
|
|
96
|
+
* and `5xx`: submit the same value again); `transport` if the consumer's
|
|
97
|
+
* transport throws (retryable: submit the same value again).
|
|
98
|
+
*/
|
|
99
|
+
submit(prepared: PreparedContractExecution): Promise<ContractExecution>;
|
|
100
|
+
/**
|
|
101
|
+
* Rebuild a prepared execution from `PreparedContractExecution.toPersisted`.
|
|
102
|
+
*
|
|
103
|
+
* The record is checked, not trusted: the body must be one {@link prepare}
|
|
104
|
+
* would have produced, byte for byte, and the authorization must be a
|
|
105
|
+
* compact ES256 `contract_execution` authorization over exactly that body
|
|
106
|
+
* and its idempotency key. This is the integrity of a stored record, not
|
|
107
|
+
* verification: the signature is DAA's to check. Its expiry is deliberately
|
|
108
|
+
* not checked — see {@link submit}.
|
|
109
|
+
*
|
|
110
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a record
|
|
111
|
+
* that fails any of those checks.
|
|
112
|
+
*/
|
|
113
|
+
restore(persisted: PersistedContractExecution): PreparedContractExecution;
|
|
114
|
+
}
|
|
@@ -0,0 +1,462 @@
|
|
|
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 _ContractExecutionsClient_transport, _ContractExecutionsClient_signing;
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ContractExecutionsClient = void 0;
|
|
33
|
+
const deviceAuthorization_1 = require("../auth/deviceAuthorization");
|
|
34
|
+
const base64url_1 = require("../crypto/base64url");
|
|
35
|
+
const serialization_1 = require("../crypto/serialization");
|
|
36
|
+
const sha256_1 = require("../crypto/sha256");
|
|
37
|
+
const errors_1 = require("../errors");
|
|
38
|
+
const PreparedContractExecution_1 = require("../models/PreparedContractExecution");
|
|
39
|
+
const requestBody_1 = require("../validation/requestBody");
|
|
40
|
+
const uuid_1 = require("../validation/uuid");
|
|
41
|
+
const contractExecutionPayload_1 = require("../wire/contractExecutionPayload");
|
|
42
|
+
const resourceRequest_1 = require("./resourceRequest");
|
|
43
|
+
const signedResource_1 = require("./signedResource");
|
|
44
|
+
/**
|
|
45
|
+
* `GET /v1/accounts/contractExecutions/{id}` — the public path, as for
|
|
46
|
+
* transfers. The create path is the registry's `canonical_path`, which
|
|
47
|
+
* `postAuthorizedResource` resolves; it is not chosen here.
|
|
48
|
+
*/
|
|
49
|
+
const CONTRACT_EXECUTION_PATH_PREFIX = '/v1/accounts/contractExecutions/';
|
|
50
|
+
/**
|
|
51
|
+
* The properties of each arm of the registry's `contract_execution` `oneOf`,
|
|
52
|
+
* in the order it names them. This is the order the signed bytes use, so it
|
|
53
|
+
* does not vary with how a caller wrote its literal.
|
|
54
|
+
*/
|
|
55
|
+
const COMMON_PROPERTIES = Object.freeze([
|
|
56
|
+
'idempotencyKey',
|
|
57
|
+
'accountId',
|
|
58
|
+
'blockchain',
|
|
59
|
+
'contractAddress',
|
|
60
|
+
'amount',
|
|
61
|
+
]);
|
|
62
|
+
const RAW_PROPERTIES = Object.freeze([...COMMON_PROPERTIES, 'callData']);
|
|
63
|
+
const ABI_PROPERTIES = Object.freeze([
|
|
64
|
+
...COMMON_PROPERTIES,
|
|
65
|
+
'abiFunctionSignature',
|
|
66
|
+
'abiParameters',
|
|
67
|
+
]);
|
|
68
|
+
const BLOCKCHAINS = Object.freeze([
|
|
69
|
+
'ETH',
|
|
70
|
+
'ARB',
|
|
71
|
+
'CBASE',
|
|
72
|
+
'OP',
|
|
73
|
+
'UNI',
|
|
74
|
+
'ARC',
|
|
75
|
+
]);
|
|
76
|
+
const EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
77
|
+
const ZERO_ADDRESS = /^0x0{40}$/;
|
|
78
|
+
const CALL_DATA = /^0x(?:[0-9a-fA-F]{2})+$/;
|
|
79
|
+
const MAX_CALL_DATA_BYTES = 16384;
|
|
80
|
+
/**
|
|
81
|
+
* Whole native-asset units: no sign, exponent, or leading integer zero; at
|
|
82
|
+
* most 20 integer and 18 fractional digits. DAA enforces the chain's own,
|
|
83
|
+
* possibly smaller, precision at runtime.
|
|
84
|
+
*/
|
|
85
|
+
const NATIVE_AMOUNT = /^(?:0|[1-9][0-9]{0,19})(?:\.[0-9]{1,18})?$/;
|
|
86
|
+
/**
|
|
87
|
+
* The canonical ABI signature grammar DAA enforces: an ASCII identifier, then elementary types — `address`,
|
|
88
|
+
* `bool`, `string`, `bytes`, `bytes1`..`bytes32`, `int8`..`int256` and
|
|
89
|
+
* `uint8`..`uint256` in steps of eight — each with at most seven `[]` or
|
|
90
|
+
* `[N]` dimensions, `N` from 1 to 1024 without leading zeros. No whitespace,
|
|
91
|
+
* names, aliases, tuples, `function`, or fixed-point types.
|
|
92
|
+
*
|
|
93
|
+
* This is syntax only. Which array forms are enabled is a runtime capability
|
|
94
|
+
* that DAA checks and can widen without an SDK release, so the SDK does not
|
|
95
|
+
* pin that list.
|
|
96
|
+
*/
|
|
97
|
+
const ELEMENTARY_TYPE = '(?:address|bool|string|bytes(?:[1-9]|[12][0-9]|3[0-2])?|u?int(?:8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256))';
|
|
98
|
+
const ARRAY_DIMENSIONS = '(?:\\[(?:[1-9][0-9]{0,2}|10[01][0-9]|102[0-4])?\\]){0,7}';
|
|
99
|
+
const ABI_TYPE = ELEMENTARY_TYPE + ARRAY_DIMENSIONS;
|
|
100
|
+
const ABI_SIGNATURE = new RegExp(`^[A-Za-z_$][A-Za-z0-9_$]*\\((?:${ABI_TYPE}(?:,${ABI_TYPE})*)?\\)$`);
|
|
101
|
+
const MAX_SIGNATURE_LENGTH = 1000;
|
|
102
|
+
/** Every property either arm can carry; none may come from the prototype chain. */
|
|
103
|
+
const ALL_PROPERTIES = Object.freeze([...RAW_PROPERTIES, 'abiFunctionSignature', 'abiParameters']);
|
|
104
|
+
/** The outer parameter array is depth one, as DAA counts it. */
|
|
105
|
+
const MAX_PARAMETER_DEPTH = 8;
|
|
106
|
+
/** Every element of every array in the tree counts, arrays included, as DAA counts it. */
|
|
107
|
+
const MAX_PARAMETER_VALUES = 1024;
|
|
108
|
+
/** DAA's limit on the exact request body, checked before anything is signed. */
|
|
109
|
+
const MAX_BODY_BYTES = 65536;
|
|
110
|
+
/**
|
|
111
|
+
* Owner-authorized contract execution from a self-custody account, plus its
|
|
112
|
+
* read.
|
|
113
|
+
*
|
|
114
|
+
* A create is two steps because a retry must be exact. {@link prepare}
|
|
115
|
+
* validates the request, serializes it **once**, and signs one
|
|
116
|
+
* `X-Device-Authorization` over those bytes. {@link submit} sends that pair,
|
|
117
|
+
* unchanged, and is what to call again after a transport failure, a `5xx`, an
|
|
118
|
+
* unreadable response, or an app restart ({@link restore} rebuilds the pair
|
|
119
|
+
* from what `PreparedContractExecution.toPersisted` stored).
|
|
120
|
+
*
|
|
121
|
+
* There is deliberately no one-call `create`. Its prepared value would not
|
|
122
|
+
* outlive a failed call, so the only retry left to the caller would be a new
|
|
123
|
+
* signature over the same body — a different `jti`, which DAA answers with
|
|
124
|
+
* `409` rather than the stored execution.
|
|
125
|
+
*
|
|
126
|
+
* The Owner authorization is the approval for this operation; there is no
|
|
127
|
+
* separate strong-customer-authentication step on this route.
|
|
128
|
+
*
|
|
129
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
130
|
+
* the `#transport` field makes the type nominal.
|
|
131
|
+
*/
|
|
132
|
+
class ContractExecutionsClient {
|
|
133
|
+
/** @internal Constructed only through the internal user-client factory. */
|
|
134
|
+
constructor(transport, signing) {
|
|
135
|
+
_ContractExecutionsClient_transport.set(this, void 0);
|
|
136
|
+
_ContractExecutionsClient_signing.set(this, void 0);
|
|
137
|
+
__classPrivateFieldSet(this, _ContractExecutionsClient_transport, transport, "f");
|
|
138
|
+
__classPrivateFieldSet(this, _ContractExecutionsClient_signing, signing, "f");
|
|
139
|
+
Object.freeze(this);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read one contract execution. Poll this until the status is `complete` or
|
|
143
|
+
* `failed`; it is the authoritative outcome.
|
|
144
|
+
*
|
|
145
|
+
* @param contractExecutionId The service-assigned UUID. A value that is not
|
|
146
|
+
* UUID-formatted is rejected locally.
|
|
147
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a rejected
|
|
148
|
+
* id or a response the SDK cannot read; `api` for a status other than
|
|
149
|
+
* `200` (an unknown or inaccessible execution is `404`); `transport` if the
|
|
150
|
+
* consumer's transport throws.
|
|
151
|
+
*/
|
|
152
|
+
async get(contractExecutionId) {
|
|
153
|
+
if (!(0, uuid_1.isUuid)(contractExecutionId)) {
|
|
154
|
+
throw (0, errors_1.contractViolation)('contractExecutionId must be a UUID');
|
|
155
|
+
}
|
|
156
|
+
return (0, resourceRequest_1.readResource)({
|
|
157
|
+
transport: __classPrivateFieldGet(this, _ContractExecutionsClient_transport, "f"),
|
|
158
|
+
path: CONTRACT_EXECUTION_PATH_PREFIX + contractExecutionId,
|
|
159
|
+
decode: contractExecutionPayload_1.toContractExecution,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Validate, serialize once, and Owner-authorize a contract execution, without
|
|
164
|
+
* sending it.
|
|
165
|
+
*
|
|
166
|
+
* Store the result (see `PreparedContractExecution.toPersisted`) before the
|
|
167
|
+
* first {@link submit} if the app must survive a restart mid-request.
|
|
168
|
+
*
|
|
169
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a request
|
|
170
|
+
* the registry schema or DAA would reject — including a fee, gas, or other
|
|
171
|
+
* unknown property, and an `abiParameters` count that does not match the
|
|
172
|
+
* signature — and for an AuthKey that is not yet registered. Nothing is
|
|
173
|
+
* signed for a rejected request.
|
|
174
|
+
*/
|
|
175
|
+
async prepare(request) {
|
|
176
|
+
const body = serializedContractExecutionBody(request);
|
|
177
|
+
const bodyBytes = body.bytes;
|
|
178
|
+
const authorization = await (0, signedResource_1.authorizeSignedPost)({
|
|
179
|
+
operation: 'contract_execution',
|
|
180
|
+
authKey: await __classPrivateFieldGet(this, _ContractExecutionsClient_signing, "f").resolveAuthKey(),
|
|
181
|
+
authKeyId: __classPrivateFieldGet(this, _ContractExecutionsClient_signing, "f").authKeyId,
|
|
182
|
+
bodyBytes,
|
|
183
|
+
});
|
|
184
|
+
return new PreparedContractExecution_1.PreparedContractExecution({
|
|
185
|
+
idempotencyKey: body.idempotencyKey,
|
|
186
|
+
bodyBytes,
|
|
187
|
+
authorization,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Send a prepared execution exactly as it was authorized.
|
|
192
|
+
*
|
|
193
|
+
* Safe to repeat: every call sends identical bytes and the identical
|
|
194
|
+
* authorization. DAA answers `201` for a new execution and `200` with the
|
|
195
|
+
* stored execution for an exact replay — including a replay after the
|
|
196
|
+
* authorization has expired — and both resolve here. A replay of a request
|
|
197
|
+
* DAA never accepted, once its authorization has expired, is refused; the
|
|
198
|
+
* recovery is a new execution with a new idempotency key, not a retry.
|
|
199
|
+
*
|
|
200
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a prepared
|
|
201
|
+
* value authorized by a different AuthKey than this user client's, for a
|
|
202
|
+
* rejected, expired, or replayed authorization DAA did not accept, and for
|
|
203
|
+
* a response the SDK cannot read — DAA may have accepted that request, so
|
|
204
|
+
* submit the same value again or poll; never prepare it again under a new
|
|
205
|
+
* key; `clock_skew` when DAA refused the authorization because the device
|
|
206
|
+
* clock was more than 60 seconds off when {@link prepare} signed it — DAA
|
|
207
|
+
* did not accept it, and resubmitting sends the same authorization, so
|
|
208
|
+
* correct the device time and treat it like an expired authorization: a
|
|
209
|
+
* new execution with a new idempotency key; `idempotency_conflict` for a `409` with
|
|
210
|
+
* `IDEMPOTENCY_KEY_REUSED`; `api` for any other status (retryable for `429`
|
|
211
|
+
* and `5xx`: submit the same value again); `transport` if the consumer's
|
|
212
|
+
* transport throws (retryable: submit the same value again).
|
|
213
|
+
*/
|
|
214
|
+
async submit(prepared) {
|
|
215
|
+
const { bodyBytes, authorization } = (0, PreparedContractExecution_1.preparedParts)(prepared);
|
|
216
|
+
if (authorizationKeyId(authorization) !== __classPrivateFieldGet(this, _ContractExecutionsClient_signing, "f").authKeyId) {
|
|
217
|
+
throw (0, errors_1.contractViolation)('the prepared contract execution was authorized by a different AuthKey');
|
|
218
|
+
}
|
|
219
|
+
return (0, signedResource_1.postAuthorizedResource)({
|
|
220
|
+
transport: __classPrivateFieldGet(this, _ContractExecutionsClient_transport, "f"),
|
|
221
|
+
operation: 'contract_execution',
|
|
222
|
+
bodyBytes,
|
|
223
|
+
authorization,
|
|
224
|
+
expectedStatuses: [201, 200],
|
|
225
|
+
decode: contractExecutionPayload_1.toContractExecution,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Rebuild a prepared execution from `PreparedContractExecution.toPersisted`.
|
|
230
|
+
*
|
|
231
|
+
* The record is checked, not trusted: the body must be one {@link prepare}
|
|
232
|
+
* would have produced, byte for byte, and the authorization must be a
|
|
233
|
+
* compact ES256 `contract_execution` authorization over exactly that body
|
|
234
|
+
* and its idempotency key. This is the integrity of a stored record, not
|
|
235
|
+
* verification: the signature is DAA's to check. Its expiry is deliberately
|
|
236
|
+
* not checked — see {@link submit}.
|
|
237
|
+
*
|
|
238
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a record
|
|
239
|
+
* that fails any of those checks.
|
|
240
|
+
*/
|
|
241
|
+
restore(persisted) {
|
|
242
|
+
(0, requestBody_1.requireBodyObject)(persisted, 'persisted contract execution');
|
|
243
|
+
(0, requestBody_1.requireKnownProperties)(persisted, ['version', 'body', 'authorization'], 'persisted contract execution');
|
|
244
|
+
const { version, body, authorization } = persisted;
|
|
245
|
+
if (version !== 1 || typeof body !== 'string' || typeof authorization !== 'string') {
|
|
246
|
+
throw (0, errors_1.contractViolation)('persisted contract execution is not a version 1 record');
|
|
247
|
+
}
|
|
248
|
+
let bodyBytes;
|
|
249
|
+
let parsed;
|
|
250
|
+
try {
|
|
251
|
+
bodyBytes = (0, base64url_1.fromBase64Url)(body);
|
|
252
|
+
parsed = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bodyBytes));
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
throw (0, errors_1.contractViolation)('persisted contract execution body is not UTF-8 JSON');
|
|
256
|
+
}
|
|
257
|
+
const projected = serializedContractExecutionBody(parsed);
|
|
258
|
+
if (!sameBytes(projected.bytes, bodyBytes)) {
|
|
259
|
+
throw (0, errors_1.contractViolation)('persisted contract execution body is not one the SDK prepared');
|
|
260
|
+
}
|
|
261
|
+
requireAuthorizationBinding(authorization, bodyBytes, projected.idempotencyKey);
|
|
262
|
+
return new PreparedContractExecution_1.PreparedContractExecution({
|
|
263
|
+
idempotencyKey: projected.idempotencyKey,
|
|
264
|
+
bodyBytes,
|
|
265
|
+
authorization,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.ContractExecutionsClient = ContractExecutionsClient;
|
|
270
|
+
_ContractExecutionsClient_transport = new WeakMap(), _ContractExecutionsClient_signing = new WeakMap();
|
|
271
|
+
/** Validate, project, and serialize once, within DAA's body limit. */
|
|
272
|
+
function serializedContractExecutionBody(request) {
|
|
273
|
+
const body = createContractExecutionBody(request);
|
|
274
|
+
const bytes = (0, serialization_1.serializeBody)(body.value);
|
|
275
|
+
if (bytes.length > MAX_BODY_BYTES) {
|
|
276
|
+
throw (0, errors_1.contractViolation)('contract execution request body exceeds 65536 bytes');
|
|
277
|
+
}
|
|
278
|
+
return { bytes, idempotencyKey: body.idempotencyKey };
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Project a validated request onto the registry's `contract_execution` shape.
|
|
282
|
+
*
|
|
283
|
+
* Each caller property is read exactly once, into the returned value, so a
|
|
284
|
+
* getter cannot pass validation with one value and serialize another. Returned
|
|
285
|
+
* rather than serialized here so {@link ContractExecutionsClient.prepare} holds
|
|
286
|
+
* the one byte slice it signs.
|
|
287
|
+
*/
|
|
288
|
+
function createContractExecutionBody(request) {
|
|
289
|
+
(0, requestBody_1.requireBodyObject)(request, 'contract execution request');
|
|
290
|
+
const record = request;
|
|
291
|
+
// `Object.keys` (which the unknown-property check reads, as `JSON.stringify`
|
|
292
|
+
// does) cannot see an inherited property, but a plain read can. Refusing one
|
|
293
|
+
// keeps "present" meaning the same thing to every check below.
|
|
294
|
+
for (const name of ALL_PROPERTIES) {
|
|
295
|
+
if (name in record && !Object.prototype.hasOwnProperty.call(record, name)) {
|
|
296
|
+
throw (0, errors_1.contractViolation)(`contract execution request property "${name}" must be its own`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const hasCallData = Object.prototype.hasOwnProperty.call(record, 'callData');
|
|
300
|
+
const hasAbi = Object.prototype.hasOwnProperty.call(record, 'abiFunctionSignature') ||
|
|
301
|
+
Object.prototype.hasOwnProperty.call(record, 'abiParameters');
|
|
302
|
+
if (hasCallData === hasAbi) {
|
|
303
|
+
throw (0, errors_1.contractViolation)('contract execution request needs exactly one of callData or abiFunctionSignature with abiParameters');
|
|
304
|
+
}
|
|
305
|
+
(0, requestBody_1.requireKnownProperties)(request, hasCallData ? RAW_PROPERTIES : ABI_PROPERTIES, 'contract execution request');
|
|
306
|
+
const idempotencyKey = record['idempotencyKey'];
|
|
307
|
+
const accountId = record['accountId'];
|
|
308
|
+
const blockchain = record['blockchain'];
|
|
309
|
+
const contractAddress = record['contractAddress'];
|
|
310
|
+
const hasAmount = Object.prototype.hasOwnProperty.call(record, 'amount');
|
|
311
|
+
const amount = record['amount'];
|
|
312
|
+
if (typeof idempotencyKey !== 'string' || !(0, uuid_1.isUuidV4)(idempotencyKey)) {
|
|
313
|
+
throw (0, errors_1.contractViolation)('idempotencyKey must be a UUID v4');
|
|
314
|
+
}
|
|
315
|
+
if (typeof accountId !== 'string' || !(0, uuid_1.isUuid)(accountId)) {
|
|
316
|
+
throw (0, errors_1.contractViolation)('accountId must be a UUID');
|
|
317
|
+
}
|
|
318
|
+
if (typeof blockchain !== 'string' || !BLOCKCHAINS.includes(blockchain)) {
|
|
319
|
+
throw (0, errors_1.contractViolation)(`blockchain must be one of ${BLOCKCHAINS.join(', ')}`);
|
|
320
|
+
}
|
|
321
|
+
if (typeof contractAddress !== 'string' ||
|
|
322
|
+
!EVM_ADDRESS.test(contractAddress) ||
|
|
323
|
+
ZERO_ADDRESS.test(contractAddress)) {
|
|
324
|
+
throw (0, errors_1.contractViolation)('contractAddress must be a non-zero 0x-prefixed 20-byte address');
|
|
325
|
+
}
|
|
326
|
+
// An omitted amount is not sent, and `undefined` is not an omission: it is a
|
|
327
|
+
// present property that `JSON.stringify` would silently drop, so the caller
|
|
328
|
+
// could not tell which body it signed.
|
|
329
|
+
if (hasAmount && (typeof amount !== 'string' || !NATIVE_AMOUNT.test(amount))) {
|
|
330
|
+
throw (0, errors_1.contractViolation)('amount must be a non-negative decimal string, e.g. "0.1"');
|
|
331
|
+
}
|
|
332
|
+
const common = {
|
|
333
|
+
idempotencyKey,
|
|
334
|
+
accountId,
|
|
335
|
+
blockchain,
|
|
336
|
+
contractAddress,
|
|
337
|
+
...(hasAmount ? { amount } : {}),
|
|
338
|
+
};
|
|
339
|
+
if (hasCallData) {
|
|
340
|
+
return { value: { ...common, callData: callDataOf(record['callData']) }, idempotencyKey };
|
|
341
|
+
}
|
|
342
|
+
const abiFunctionSignature = record['abiFunctionSignature'];
|
|
343
|
+
const abiParameters = record['abiParameters'];
|
|
344
|
+
if (typeof abiFunctionSignature !== 'string' ||
|
|
345
|
+
abiFunctionSignature.length > MAX_SIGNATURE_LENGTH ||
|
|
346
|
+
!ABI_SIGNATURE.test(abiFunctionSignature)) {
|
|
347
|
+
throw (0, errors_1.contractViolation)('abiFunctionSignature must be a canonical signature such as approve(address,uint256)');
|
|
348
|
+
}
|
|
349
|
+
if (!Array.isArray(abiParameters)) {
|
|
350
|
+
throw (0, errors_1.contractViolation)('abiParameters must be an array; use [] for no arguments');
|
|
351
|
+
}
|
|
352
|
+
if (abiParameters.length !== argumentCount(abiFunctionSignature)) {
|
|
353
|
+
throw (0, errors_1.contractViolation)('abiParameters must have one value per signature argument');
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
value: {
|
|
357
|
+
...common,
|
|
358
|
+
abiFunctionSignature,
|
|
359
|
+
abiParameters: abiParametersOf(abiParameters, 1, { values: 0 }),
|
|
360
|
+
},
|
|
361
|
+
idempotencyKey,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Top-level argument count of a signature that already matched
|
|
366
|
+
* {@link ABI_SIGNATURE}. Tuples are outside that grammar, so a comma always
|
|
367
|
+
* separates two top-level types.
|
|
368
|
+
*/
|
|
369
|
+
function argumentCount(signature) {
|
|
370
|
+
const inner = signature.slice(signature.indexOf('(') + 1, -1);
|
|
371
|
+
return inner === '' ? 0 : inner.split(',').length;
|
|
372
|
+
}
|
|
373
|
+
function callDataOf(callData) {
|
|
374
|
+
if (typeof callData !== 'string' || !CALL_DATA.test(callData)) {
|
|
375
|
+
throw (0, errors_1.contractViolation)('callData must be 0x-prefixed, even-length hex of at least one byte');
|
|
376
|
+
}
|
|
377
|
+
if ((callData.length - 2) / 2 > MAX_CALL_DATA_BYTES) {
|
|
378
|
+
throw (0, errors_1.contractViolation)('callData must be at most 16384 bytes');
|
|
379
|
+
}
|
|
380
|
+
return callData;
|
|
381
|
+
}
|
|
382
|
+
/** A validated copy of one array level of the parameter tree. */
|
|
383
|
+
function abiParametersOf(values, depth, total) {
|
|
384
|
+
if (depth > MAX_PARAMETER_DEPTH) {
|
|
385
|
+
throw (0, errors_1.contractViolation)('abiParameters may nest at most eight array levels');
|
|
386
|
+
}
|
|
387
|
+
const copy = [];
|
|
388
|
+
for (const value of values) {
|
|
389
|
+
total.values += 1;
|
|
390
|
+
if (total.values > MAX_PARAMETER_VALUES) {
|
|
391
|
+
throw (0, errors_1.contractViolation)('abiParameters may hold at most 1024 values in total');
|
|
392
|
+
}
|
|
393
|
+
copy.push(abiParameterOf(value, depth, total));
|
|
394
|
+
}
|
|
395
|
+
return copy;
|
|
396
|
+
}
|
|
397
|
+
function abiParameterOf(value, depth, total) {
|
|
398
|
+
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
399
|
+
return value;
|
|
400
|
+
}
|
|
401
|
+
if (typeof value === 'number') {
|
|
402
|
+
// A safe integer is the only number whose `JSON.stringify` spelling is the
|
|
403
|
+
// value the caller wrote. `-0` is safe but spells `0`, which is the same
|
|
404
|
+
// integer, so it is not a change of meaning.
|
|
405
|
+
if (!Number.isSafeInteger(value)) {
|
|
406
|
+
throw (0, errors_1.contractViolation)('abiParameters numbers must be safe integers; pass larger integers as decimal strings');
|
|
407
|
+
}
|
|
408
|
+
return value;
|
|
409
|
+
}
|
|
410
|
+
if (Array.isArray(value)) {
|
|
411
|
+
return abiParametersOf(value, depth + 1, total);
|
|
412
|
+
}
|
|
413
|
+
throw (0, errors_1.contractViolation)('abiParameters values must be strings, booleans, safe integers, or arrays of those');
|
|
414
|
+
}
|
|
415
|
+
/** The `kid` of a compact JWS this SDK produced, or `null` if it cannot be read. */
|
|
416
|
+
function authorizationKeyId(authorization) {
|
|
417
|
+
const header = (0, deviceAuthorization_1.jwsSegmentJson)(authorization, 0);
|
|
418
|
+
return header !== null && typeof header['kid'] === 'string' ? header['kid'] : null;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Check that a restored authorization is the `contract_execution` one for
|
|
422
|
+
* these exact bytes. This is integrity of a stored record, not verification:
|
|
423
|
+
* the signature itself is DAA's to check.
|
|
424
|
+
*/
|
|
425
|
+
function requireAuthorizationBinding(authorization, bodyBytes, idempotencyKey) {
|
|
426
|
+
const profile = (0, deviceAuthorization_1.deviceAuthorizationProfile)('contract_execution');
|
|
427
|
+
const header = (0, deviceAuthorization_1.jwsSegmentJson)(authorization, 0);
|
|
428
|
+
const claims = (0, deviceAuthorization_1.jwsSegmentJson)(authorization, 1);
|
|
429
|
+
if (header === null ||
|
|
430
|
+
claims === null ||
|
|
431
|
+
header['alg'] !== 'ES256' ||
|
|
432
|
+
authorizationKeyId(authorization) === null ||
|
|
433
|
+
!isJoseEs256Signature(authorization.split('.')[2] ?? '') ||
|
|
434
|
+
claims['discriminator'] !== profile.discriminator ||
|
|
435
|
+
claims['schema_version'] !== profile.schemaVersion ||
|
|
436
|
+
claims['method'] !== profile.method ||
|
|
437
|
+
claims['canonical_path'] !== profile.canonicalPath ||
|
|
438
|
+
claims['idempotency_key'] !== idempotencyKey ||
|
|
439
|
+
claims['body_sha256'] !== (0, base64url_1.toBase64Url)((0, sha256_1.sha256)(bodyBytes))) {
|
|
440
|
+
throw (0, errors_1.contractViolation)('persisted contract execution authorization does not match its body');
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** A base64url segment that decodes to the 64-byte `R || S` ES256 signature. */
|
|
444
|
+
function isJoseEs256Signature(segment) {
|
|
445
|
+
try {
|
|
446
|
+
return (0, base64url_1.fromBase64Url)(segment).length === 64;
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function sameBytes(a, b) {
|
|
453
|
+
if (a.length !== b.length) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
for (let i = 0; i < a.length; i++) {
|
|
457
|
+
if (a[i] !== b[i]) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return true;
|
|
462
|
+
}
|